-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (34 loc) · 844 Bytes
/
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
package main
import (
"os"
"os/signal"
"syscall"
"github.com/liuwqiang/tykd/config"
"github.com/liuwqiang/tykd/service"
log "github.com/sirupsen/logrus"
)
var (
confPaths = []string{
"tykd.conf",
// TODO: add ~/.config/tyk/tyk.conf here?
"/etc/tykd/tykd.conf",
}
)
func main() {
svc, err := service.Spawn()
if err != nil {
log.Errorf("Failed to start service: err=(%s)", err)
os.Exit(1)
}
globalConf := config.Config{}
if err := config.Load(confPaths, &globalConf); err != nil {
log.Errorf("Failed to start service: err=(%s)", err)
os.Exit(1)
}
// Spawn OS signal listener to ensure graceful stop.
osSigCh := make(chan os.Signal, 1)
signal.Notify(osSigCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
// Wait for a quit signal and terminate the service when it is received.
<-osSigCh
svc.Stop()
}