forked from shamanec/GADS-devices-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (25 loc) · 912 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
package main
import (
"flag"
"fmt"
"github.com/shamanec/GADS-devices-provider/device"
_ "github.com/shamanec/GADS-devices-provider/docs"
"github.com/shamanec/GADS-devices-provider/router"
"github.com/shamanec/GADS-devices-provider/util"
)
func main() {
port_flag := flag.String("port", "10001", "The port to run the server on")
log_level := flag.String("log_level", "info", "The log level of the provider app - debug, info or error")
flag.Parse()
util.SetupConfig()
util.InitMongoClient()
defer util.CloseMongoConn()
util.SetupLogging(*log_level)
util.UpsertProviderMongo()
util.ProviderLogger.LogInfo("provider_setup", fmt.Sprintf("Starting provider on port `%v`", *port_flag))
// Start a goroutine that will update devices on provider start
go device.UpdateDevices()
// Handle the endpoints
r := router.HandleRequests()
r.Run(fmt.Sprintf(":%v", util.Config.EnvConfig.HostPort))
}