-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (61 loc) · 1.41 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
package main
import (
"fmt"
"github.com/jpillora/overseer"
"github.com/jpillora/overseer/fetcher"
"github.com/wgjtyu/goutil/overseer_fetcher"
"go.uber.org/zap"
"math/rand"
"os"
"runtime"
"time"
"wfRadius/src/config"
"wfRadius/src/request"
"wfRadius/src/root/startup"
"wfRadius/src/ws"
"wfRadius/util"
)
func prog(state overseer.State) {
rand.Seed(time.Now().UnixNano())
app, err := BuildApp()
if err != nil {
zap.L().Error("启动出错", zap.Error(err))
os.Exit(-1)
}
// 输出当前版本和构建时间
zap.L().Info("Start",
zap.String("GOOS", runtime.GOOS),
zap.String("GOARCH", runtime.GOARCH),
zap.String("GitTag", util.GitTag),
zap.String("BuildTime", util.BuildTime))
// 配置Http请求
request.Init(app.Config.Token, app.Config.HTTPBackend)
go func() {
select {
case <-ws.CmdQuit:
app.Shutdown()
case <-state.GracefulShutdown:
app.Shutdown()
}
}()
app.Run() // 在shutdown之前,会停在这里
app.WaitForEnd()
}
func main() {
cfg := startup.InitCfg()
var f fetcher.Interface
if cfg.Environment == config.EnvirIsDev {
f = &fetcher.File{
Path: "wfRadius.next",
}
} else if cfg.Environment == config.EnvirIsProd {
f = &overseerfetcher.HttpFetcher{
URL: fmt.Sprintf("https://afile.atsuas.cn/file/wfRadius_%s_%s", runtime.GOOS, runtime.GOARCH),
WorkDirectory: os.Args[1],
}
}
overseer.Run(overseer.Config{
Program: prog,
Fetcher: f,
})
}