-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (47 loc) · 1.07 KB
/
main.go
File metadata and controls
57 lines (47 loc) · 1.07 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
package main
import (
"flag"
"fmt"
"github.com/ethereum/agentCard/api"
"github.com/ethereum/agentCard/config"
"github.com/ethereum/agentCard/db"
"github.com/ethereum/agentCard/log"
"github.com/sirupsen/logrus"
"os"
)
const CONTRACTLEN = 42
var (
conffile string
env string
)
func init() {
flag.StringVar(&conffile, "conf", "config.yaml", "conf file")
flag.StringVar(&env, "env", "prod", "Deploy environment: [ prod | test ]. Default value: prod")
}
func main() {
var err error
if config.Conf, err = config.LoadConfig("./conf"); err != nil {
logrus.Error("🚀 Could not load environment variables")
panic(err)
}
flag.Parse()
err = log.Init("agentCard", &config.Conf)
if err != nil {
log.Fatal(err)
}
dbConnection, err := db.NewMysql(&config.Conf)
if err != nil {
logrus.Fatalf("connect to dbConnection error:%v", err)
}
apiService := api.NewApiService(dbConnection, &config.Conf)
go apiService.Run()
//listen kill signal
closeCh := make(chan os.Signal, 1)
for {
select {
case <-closeCh:
fmt.Printf("receive os close sigal")
return
}
}
}