-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (36 loc) · 942 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
package main
import (
"3mdeb/device-controller/pkg/config"
"3mdeb/device-controller/pkg/controller"
"3mdeb/device-controller/pkg/server"
"flag"
"log"
)
var (
version = "0.1.0"
configDirPath = "./config"
configFilePath = flag.String("c", configDirPath+"/config.json",
"path to configuration file")
schemaConfigFilePath = flag.String("s", configDirPath+"/config.schema.json",
"path to schema of configuration file")
)
func main() {
flag.Parse()
log.Println("device-controller version:", version)
cfg, err := config.LoadConfig(*configFilePath, *schemaConfigFilePath)
if err != nil {
log.Println(err)
return
}
log.Println("Initializing controllers")
err = controller.Init(cfg.Devices)
if err != nil {
log.Printf("Error during initialization: %s", err.Error())
}
log.Println("Initializing server")
defer func() {
log.Println("Cleaning controllers")
controller.Clean()
}()
server.StartServer(*cfg)
}