-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (33 loc) · 826 Bytes
/
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
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/HelloLingC/moon-counter/common"
"github.com/HelloLingC/moon-counter/database"
"github.com/HelloLingC/moon-counter/server"
"gopkg.in/yaml.v2"
)
func main() {
configPath := flag.String("c", "config.yaml", "The path to config file")
flag.Parse()
cfgFile, err := os.ReadFile(*configPath)
if err != nil {
log.Fatal("Error reading config file:", err)
}
var config common.Config
err = yaml.Unmarshal(cfgFile, &config)
if err != nil {
log.Fatal("Error unmarshaling YAML:", err)
}
db, err := database.NewDBAdapter(config.DBCfg.Type, &config.DBCfg)
if err != nil {
log.Fatal("Err DB Init:", err)
}
db.InitDB()
defer db.CloseDB()
server.LoadAssets(fmt.Sprintf("assets/%s", config.ImgTheme))
s := server.NewInstance(&config, db)
s.Start()
}