-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (47 loc) · 1.26 KB
/
main.go
File metadata and controls
60 lines (47 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"decentralized-explorer-backend/ipfs"
"fmt"
"log"
"net/http"
"os"
)
func main() {
appDir, err := getAppDir()
if err != nil {
fmt.Printf("Error getting application directory: %v\n", err)
os.Exit(1)
}
// Setup IPFS environment
err = ipfs.NewIPFSSetup(appDir)
// if err := ipfsSetup.EnsureIPFS();
if err != nil {
fmt.Printf("IPFS setup failed: %v\n", err)
os.Exit(1)
}
daemonCmd, err := ipfs.StartDaemon(appDir)
if err != nil {
log.Fatalf("Failed to start daemon: %v", err)
}
defer daemonCmd.Process.Kill()
if err := setupDatabase(); err != nil {
log.Fatal("Database setup failed:", err)
}
defer db.Close()
router := setupRoutes()
// checkTokenCount()
// if err := syncMissingCurrentOwners(); err != nil {
// log.Println("Error during initial sync:", err)
// }
// Periodic weekly sync to check newly minted tokens(runs in the background)
go startWeeklySync()
go startDailyPinCheck()
// err = checkPins("QmQPG1tw3TqEbQGvs8AS89LWNsWmn9zzoPcyZbSPucdXne")
// if err != nil {
// log.Println("Error checking pins:", err)
// }
log.Println("Server started on :3000")
handlerWithCORS := enableCORS(router)
log.Fatal(http.ListenAndServe(":3000", handlerWithCORS))
// log.Fatal(http.ListenAndServe(":3000", router))
}