/
main.go
82 lines (66 loc) · 1.68 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
"flag"
"github.com/aaronchen2k/deeptest/cmd/agent/serve"
"github.com/aaronchen2k/deeptest/cmd/agent/v1"
"github.com/aaronchen2k/deeptest/internal/pkg/consts"
"github.com/aaronchen2k/deeptest/internal/pkg/core/cron"
"github.com/aaronchen2k/deeptest/internal/pkg/helper/websocket"
"github.com/aaronchen2k/deeptest/internal/server/core/dao"
"github.com/aaronchen2k/deeptest/pkg/consts"
"github.com/aaronchen2k/deeptest/pkg/lib/log"
"github.com/facebookgo/inject"
"github.com/fatih/color"
"github.com/sirupsen/logrus"
"os"
)
var (
AppVersion string
BuildTime string
GoVersion string
GitHash string
flagSet *flag.FlagSet
)
// @title 乐研API文档
// @version 1.0
// @contact.name API Support
func main() {
flagSet = flag.NewFlagSet("deeptest", flag.ContinueOnError)
flagSet.IntVar(&consts.Port, "p", 0, "")
flagSet.BoolVar(&_consts.Verbose, "verbose", false, "")
flagSet.Parse(os.Args[1:])
websocketHelper.InitMq()
agent := agentServe.Init()
if agent == nil {
return
}
injectModule(agent)
agent.Start()
_logUtils.Infof("start agent")
}
func injectModule(ws *agentServe.AgentServer) {
var g inject.Graph
g.Logger = logrus.StandardLogger()
cron := cron.NewServerCron()
cron.Init()
indexModule := v1.NewIndexModule()
// inject objects
if err := g.Provide(
&inject.Object{Value: dao.GetDB("")},
&inject.Object{Value: cron},
&inject.Object{Value: indexModule},
); err != nil {
logrus.Fatalf("provide usecase objects to the Graph: %v", err)
}
err := g.Populate()
if err != nil {
logrus.Fatalf("populate the incomplete Objects: %v", err)
}
ws.AddModule(indexModule.Party())
}
func init() {
cleanup()
}
func cleanup() {
color.Unset()
}