forked from keep-starknet-strange/art-peace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (43 loc) · 1.36 KB
/
main.go
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
package main
import (
"flag"
"github.com/keep-starknet-strange/art-peace/backend/config"
"github.com/keep-starknet-strange/art-peace/backend/core"
"github.com/keep-starknet-strange/art-peace/backend/routes"
)
func isFlagSet(name string) bool {
found := false
flag.Visit(func(f *flag.Flag) {
if f.Name == name {
found = true
}
})
return found
}
func main() {
canvasConfigFilename := flag.String("canvas-config", config.DefaultCanvasConfigPath, "Canvas config file")
databaseConfigFilename := flag.String("database-config", config.DefaultDatabaseConfigPath, "Database config file")
backendConfigFilename := flag.String("backend-config", config.DefaultBackendConfigPath, "Backend config file")
production := flag.Bool("production", false, "Production mode")
flag.Parse()
canvasConfig, err := config.LoadCanvasConfig(*canvasConfigFilename)
if err != nil {
panic(err)
}
databaseConfig, err := config.LoadDatabaseConfig(*databaseConfigFilename)
if err != nil {
panic(err)
}
backendConfig, err := config.LoadBackendConfig(*backendConfigFilename)
if err != nil {
panic(err)
}
if isFlagSet("production") {
backendConfig.Production = *production
}
databases := core.NewDatabases(databaseConfig)
defer databases.Close()
core.ArtPeaceBackend = core.NewBackend(databases, canvasConfig, backendConfig)
routes.InitRoutes()
core.ArtPeaceBackend.Start()
}