-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
62 lines (46 loc) · 1.24 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
package main
import (
"github.com/golang/protobuf/proto"
"github.com/thejerf/suture"
"github.com/tuarrep/sounddrop/service"
"github.com/tuarrep/sounddrop/util"
"os"
"os/signal"
)
// Rev is set on build time and should contain the git commit
var rev = ""
func main() {
util.InitLogger()
log := util.GetContextLogger("main.go", "main")
log.Info("Starting main process...")
myID := util.GetMyID()
log.Info("I'm known on mesh by: ", myID.String())
stop := make(chan os.Signal)
signal.Notify(stop, os.Interrupt)
sb := util.GetServiceBag()
sb.DeviceID = myID
supervisor := suture.NewSimple("supervisor")
messenger := &service.Messenger{Message: make(chan proto.Message)}
supervisor.Add(messenger)
server := &service.Server{Messenger: messenger}
supervisor.Add(server)
mesher := &service.Mesher{Messenger: messenger}
supervisor.Add(mesher)
if sb.Config.Streamer.AutoStart {
streamer := &service.Streamer{Messenger: messenger}
supervisor.Add(streamer)
} //else {
player := &service.Player{Messenger: messenger}
supervisor.Add(player)
//}
supervisor.ServeBackground()
log.Info("Main process started. Revision: ", rev)
for {
select {
case <-stop:
supervisor.Stop()
log.Info("Clean exit. \n")
os.Exit(0)
}
}
}