-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (50 loc) · 1.11 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
63
64
65
66
package main
import (
"flag"
"github.com/naueramant/mir/internal/assets"
"github.com/naueramant/mir/internal/browser"
"github.com/naueramant/mir/internal/config"
"github.com/naueramant/mir/internal/jobs"
"github.com/naueramant/mir/internal/utils"
"github.com/sirupsen/logrus"
)
var (
c *config.Configuration
bm *browser.BrowserManager
js *jobs.JobScheduler
configPath = flag.String("config", "screen.yaml", "path to screen configuration")
)
func main() {
flag.Parse()
logrus.Infof("Using configuration file %s", *configPath)
go utils.Watch(*configPath, func() {
logrus.Infoln("Configuration file changed")
stop()
start()
})
start()
select {} // Do not terminate
}
func start() {
c, err := config.Load(*configPath)
if err != nil {
logrus.Error(err)
}
as, err := assets.NewServer()
if err != nil {
logrus.Error(err)
}
go func() {
if err := as.Start(); err != nil {
logrus.WithError(err).Fatal("Failed to start assets server")
}
}()
bm = browser.NewBrowserManager(c, as)
go bm.Start()
js = jobs.NewJobScheduler(c, bm, as)
go js.Start()
}
func stop() {
bm.Close()
js.Stop()
}