-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
56 lines (46 loc) · 1.56 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
package main
import (
lamassu "github.com/lamassuiot/lamassuiot/v2/pkg/assemblers"
"github.com/lamassuiot/lamassuiot/v2/pkg/config"
"github.com/lamassuiot/lamassuiot/v2/pkg/helpers"
"github.com/lamassuiot/lamassuiot/v2/pkg/models"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
var (
version string = "v0" // api version
sha1ver string = "-" // sha1 revision used to build the program
buildTime string = "devTS" // when the executable was built
)
func main() {
log.SetFormatter(helpers.LogFormatter)
log.Infof("starting api: version=%s buildTime=%s sha1ver=%s", version, buildTime, sha1ver)
conf, err := config.LoadConfig[config.CAConfig]()
if err != nil {
log.Fatalf("something went wrong while loading config. Exiting: %s", err)
}
globalLogLevel, err := log.ParseLevel(string(conf.Logs.Level))
if err != nil {
log.Warn("unknown log level. defaulting to 'info' log level")
globalLogLevel = log.InfoLevel
}
log.SetLevel(globalLogLevel)
log.Infof("global log level set to '%s'", globalLogLevel)
confBytes, err := yaml.Marshal(conf)
if err != nil {
log.Fatalf("could not dump yaml config: %s", err)
}
log.Debugf("===================================================")
log.Debugf("%s", confBytes)
log.Debugf("===================================================")
_, _, err = lamassu.AssembleCAServiceWithHTTPServer(*conf, models.APIServiceInfo{
Version: version,
BuildSHA: sha1ver,
BuildTime: buildTime,
})
if err != nil {
log.Fatalf("could not run CA Server. Exiting: %s", err)
}
forever := make(chan struct{})
<-forever
}