-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (44 loc) · 1017 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
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"syscall"
"github.com/alecthomas/kong"
"github.com/prometheus/client_golang/prometheus"
"github.com/zbindenren/king"
"github.com/zbindenren/king/_example/cmd"
"go.uber.org/zap"
)
// set variables with goreleaser
var (
version = "1.0.0"
date = "2020-09-22T11:11:10+02:00"
commit = "123456789"
)
const appName = "example"
func main() {
cli := cmd.CLI{}
registry := prometheus.NewRegistry()
logger, _ := zap.NewProduction()
defer logger.Sync() // nolint: errcheck
l := logger.Sugar()
b, err := king.NewBuildInfo(version,
king.WithDateString(date),
king.WithRevision(commit),
king.WithLocation("Europe/Zurich"),
)
if err != nil {
l.Fatal(err)
}
app := kong.Parse(&cli, king.DefaultOptions(
king.Config{
Name: appName,
Description: "Daeira cli and server.",
BuildInfo: b,
},
)...)
if cli.Profiler.Enabled {
cli.Profiler.New(syscall.SIGUSR2).Start()
}
if err := app.Run(&cli.Globals, l, registry); err != nil {
l.Fatal(err)
}
}