-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (53 loc) · 1.58 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
57
58
59
60
61
62
63
64
65
66
package main
import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
syslog "log"
"medical-zkml-backend/api"
"medical-zkml-backend/internal/base"
"medical-zkml-backend/internal/db"
"medical-zkml-backend/internal/handlers"
"medical-zkml-backend/internal/middleware"
"medical-zkml-backend/internal/plugin/exec/giza"
"medical-zkml-backend/internal/plugin/prediction_module_interface"
"medical-zkml-backend/pkg/config"
"medical-zkml-backend/pkg/log"
)
func main() {
// base.ExpectCheck()
// read configuration
conf := config.NewConfig()
// Load Log
if err := log.InitLogger(conf); err != nil {
panic("Log initialization failed")
}
zap.L().Info("Log initialization successful")
// Load MySQL Connection
db.InitMysql(conf)
// Load Disease Info
disease := handlers.NewDisease(base.GetDiseaseInfo(conf))
zap.L().Info("Disease module initialization successful")
prediction_module_interface.Register("Docker")
zap.L().Info("Cairo module initialization successful")
// Load Module List
modules := base.GetModuleList(conf)
operator := handlers.Operator{
Modules: modules,
}
r := gin.Default()
r.Use(middleware.CORSMiddleware())
r.Use(log.GinLogger(), log.GinRecovery(true))
// Register disease Module
api.RegisterHandlers(r, handlers.Medical{
Disease: disease,
Operator: operator,
GizaRunner: giza.NewGizaRunner(conf),
})
//gin.DefaultWriter = io.Writer(os.Stdout)
addr := ":3001"
listener := "http://0.0.0.0:"
zap.L().Info("server start", zap.String("host", listener+conf.GetString("http.port")))
if err := r.Run(addr); err != nil {
syslog.Panic("err:", err)
}
}