-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
60 lines (48 loc) · 981 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
52
53
54
55
56
57
58
59
60
package main
import (
"os"
"os/signal"
"github.com/gocontrib/pubsub"
_ "github.com/gocontrib/pubsub/nats"
"github.com/sergeyt/pandora/modules/auth"
"github.com/sergeyt/pandora/modules/cloudstore"
"github.com/sergeyt/pandora/modules/config"
"github.com/sergeyt/pandora/modules/dgraph"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetOutput(os.Stdout)
restart := make(chan bool)
die := make(chan bool)
sig := make(chan os.Signal)
signal.Notify(sig, os.Interrupt, os.Kill)
go func() {
<-sig
die <- true
}()
go start(restart)
<-die
stop()
}
func start(restart chan bool) {
cloudstore.InitStore()
dgraph.InitSchema()
auth.InitUsers()
startHub()
// go elasticsearch.MutationObserver(restart)
startServer()
}
func stop() {
pubsub.Cleanup()
stopServer()
}
func startHub() {
conf := pubsub.HubConfig{
"driver": "nats",
"url": config.NatsURL,
}
err := pubsub.Init(conf)
if err != nil {
log.Fatalf("cannot initialize hub")
}
}