forked from gluster/glusterd2
/
main.go
44 lines (35 loc) · 792 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
package main
import (
"os"
"os/signal"
"github.com/kshlm/glusterd2/commands"
"github.com/kshlm/glusterd2/context"
log "github.com/Sirupsen/logrus"
)
func main() {
log.Info("GlusterD starting")
context.Init()
for _, c := range commands.Commands {
context.Rest.SetRoutes(c.Routes())
}
sigCh := make(chan os.Signal)
signal.Notify(sigCh)
go func() {
for s := range sigCh {
log.WithField("signal", s).Debug("Signal recieved")
switch s {
case os.Interrupt:
log.WithField("signal", s).Info("Recieved SIGTERM. Stopping GlusterD.")
context.Rest.Stop()
log.Info("Termintaing GlusterD.")
os.Exit(0)
default:
continue
}
}
}()
err := context.Rest.Listen()
if err != nil {
log.Fatal("Could not start GlusterD Rest Server. Aborting.")
}
}