-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (38 loc) · 908 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
package main
import (
"github.com/evkuzin/weatherstation/config"
"github.com/evkuzin/weatherstation/weather_station/impl"
"net/http"
"os"
"sync"
"github.com/sirupsen/logrus"
)
func main() {
logger := &logrus.Logger{
Out: os.Stdout,
Formatter: &logrus.TextFormatter{},
Level: logrus.InfoLevel,
ReportCaller: true,
}
wg := &sync.WaitGroup{}
conf, err := config.NewConfig("config.yaml")
if err != nil {
logger.Errorf("cannot parse config: %s", err)
os.Exit(1)
}
ws := impl.NewWeatherStation()
err = ws.Init(conf, logger)
if err != nil {
logger.Errorf("cannot init weather station: %s", err)
os.Exit(1)
}
logger.Info("peripheral init complete...")
wg.Add(1)
go ws.Start()
err = http.ListenAndServe(":8080", ws)
if err != nil {
logger.Warnf("Cannot start stats server. %v", err.Error())
}
wg.Wait()
logger.Info("all threads killed, shutdown...")
}