-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
68 lines (54 loc) · 1.3 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
57
58
59
60
61
62
63
64
65
66
67
68
//nolint:gochecknoglobals
package main
import (
"fmt"
"runtime"
"github.com/nameserver-systems/pdns-distribute/internal/app/pdns-api-proxy/internalserviceproxy"
"github.com/nameserver-systems/pdns-distribute/internal/pkg/servutils"
msframe "github.com/nameserver-systems/pdns-distribute/pkg/microservice"
"github.com/nameserver-systems/pdns-distribute/pkg/microservice/logger"
)
var (
version = "dev"
commit = "none"
date = "unknown"
goversion = ""
)
func main() {
setGoBuildVersion()
printBuildInfo()
ms := msframe.Microservice{
Name: "pdns-api-proxy",
Version: version,
}
startService(&ms)
go startProxy(&ms)
servutils.WaitToShutdownServer(&ms, func() {
closeService(&ms)
})
}
func setGoBuildVersion() {
goversion = runtime.Version()
}
func printBuildInfo() {
output := fmt.Sprintf("build v%v, commit %v, built with %v, built at %v", version, commit, goversion, date)
logger.InfoLog(output)
}
func startService(ms *msframe.Microservice) {
err := ms.StartService()
if err != nil {
logger.FatalErrLog(err)
}
}
func closeService(ms *msframe.Microservice) {
err := ms.CloseMicroservice()
if err != nil {
logger.FatalErrLog(err)
}
}
func startProxy(ms *msframe.Microservice) {
err := internalserviceproxy.StartProxy(ms)
if err != nil {
logger.FatalErrLog(err)
}
}