-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (31 loc) · 907 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 (
_ "embed"
"net/http"
"github.com/alecthomas/kong"
kongyaml "github.com/alecthomas/kong-yaml"
"github.com/exaring/bulk-loagen/pkg/bulkloagen"
"github.com/exaring/bulk-loagen/pkg/config"
"go.uber.org/zap"
)
func main() {
logger, _ := zap.NewProduction()
defer logger.Sync()
zap.ReplaceGlobals(logger)
cfg := &config.Config{}
parser, err := kong.New(cfg, kong.Configuration(kongyaml.Loader, "/config.yaml", "config.yaml"))
if err != nil {
logger.Fatal("loading config.yaml", zap.Error(err))
}
_, err = parser.Parse(nil)
if err != nil {
logger.Fatal("parsing config", zap.Error(err))
}
svc, err := bulkloagen.NewService(cfg)
if err != nil {
logger.Fatal("instantiating service", zap.Error(err))
}
if err := http.ListenAndServe(cfg.ListenAddr, svc); err != nil {
logger.Fatal("listening", zap.String("listenAddr", cfg.ListenAddr), zap.Error(err))
}
}