-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (61 loc) · 1.39 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
package main
import (
"github.com/hlhv/hlhv-queen/conf"
"github.com/hlhv/hlhv-queen/srvhttps"
"github.com/hlhv/hlhv-queen/wrangler"
"github.com/hlhv/scribe"
"os"
"os/signal"
"syscall"
)
func main() {
ParseArgs()
scribe.SetLogLevel(options.logLevel)
arm()
fire()
// create sigint handler
sigintNotify := make(chan os.Signal, 1)
signal.Notify(sigintNotify, os.Interrupt, syscall.SIGTERM)
<-sigintNotify
scribe.PrintProgress(scribe.LogLevelNormal, "shutting down")
srvhttps.Close()
wrangler.Close()
scribe.PrintDone(scribe.LogLevelNormal, "exiting")
scribe.Stop()
os.Exit(0)
}
func arm() {
var err error
scribe.PrintProgress(scribe.LogLevelNormal, "starting hlhv queen cell")
err = conf.Load(options.confPath)
if err != nil {
scribe.PrintWarning(
scribe.LogLevelError,
"could not load conf: "+err.Error())
scribe.PrintWarning(
scribe.LogLevelError,
"using default configuration")
}
err = wrangler.Arm()
if err != nil {
scribe.PrintFatal(
scribe.LogLevelError,
"could not arm wrangler: "+err.Error())
return
}
err = srvhttps.Arm()
if err != nil {
scribe.PrintFatal(
scribe.LogLevelError,
"could not arm srvhttps: "+err.Error())
return
}
}
func fire() {
scribe.PrintProgress(scribe.LogLevelNormal, "firing")
go wrangler.Fire()
go srvhttps.Fire()
scribe.PrintDone(
scribe.LogLevelNormal,
"startup sequence complete, resuming normal operation")
}