forked from VKCOM/kive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (41 loc) · 930 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
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"github.com/sirupsen/logrus"
"github.com/VKCOM/kive/ktypes"
"github.com/VKCOM/kive/noop_api"
"github.com/VKCOM/kive/worker"
"os"
"os/signal"
"syscall"
)
func init() {
logrus.SetLevel(logrus.DebugLevel)
logrus.Info("Initializing kive")
ktypes.ApiInst = &noop_api.NoopApi{}
}
func main() {
configPath := flag.String("config", "default", "configuration path")
flag.Parse()
c := worker.NewConfig(*configPath)
err := ktypes.ApiInst.Serve()
if err != nil {
logrus.Panic("Cannot start api ", err)
}
w, err := worker.NewWorker(c)
if err != nil {
logrus.Panic("Cannot create worker ", err)
}
err = w.Listen()
if err != nil {
logrus.Panic("Cannot listen worker ", err)
}
err = w.Serve()
if err != nil {
logrus.Panic("Cannot serve worker ", err)
}
sigch := make(chan os.Signal)
signal.Notify(sigch, syscall.SIGINT, syscall.SIGTERM)
logrus.Info(<-sigch)
w.Stop()
}