-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (54 loc) · 1.14 KB
/
main.go
File metadata and controls
66 lines (54 loc) · 1.14 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
61
62
63
64
65
66
package main
import (
"context"
"flag"
"fmt"
"os"
"runtime"
"github.com/dlvlabs/ibcmon/alert"
"github.com/dlvlabs/ibcmon/app"
"github.com/dlvlabs/ibcmon/logger"
"github.com/dlvlabs/ibcmon/server"
"github.com/BurntSushi/toml"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
ctx := context.Background()
cfgPath := flag.String("config", "", "Config file")
flag.Parse()
if *cfgPath == "" {
panic("Error: Please input config file path with -config flag.")
}
f, err := os.ReadFile(*cfgPath)
if err != nil {
panic(err)
}
cfg := app.Config{}
err = toml.Unmarshal(f, &cfg)
if err != nil {
panic(err)
}
if cfg.General.LogLevel == "production" {
logger.InitLogger(true)
} else {
logger.InitLogger(false)
}
title := "ibcmon"
tgTitle := fmt.Sprintf("🤖 %s 🤖", title)
alert.SetTg(cfg.TG.Enable, tgTitle, cfg.TG.Token, cfg.TG.ChatID)
app, error := app.NewApp(ctx, cfg)
if error != nil {
panic(error)
}
server := server.NewServer(&app.Store, cfg.General.ListenPort, title)
go func() {
if err := server.Run(); err != nil {
panic(err)
}
}()
err = app.Run(ctx)
if err != nil {
logger.Error(err)
return
}
}