This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
68 lines (50 loc) · 1.5 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
package main
import (
"os"
"os/signal"
"syscall"
"github.com/bygui86/kubernetes-tests/applications/log-server/kubernetes"
"github.com/bygui86/kubernetes-tests/applications/log-server/rest"
"github.com/bygui86/kubernetes-tests/applications/log-server/utils/logger"
)
// main -
func main() {
logger.Log.Infoln("[MAIN] Starting log-server...")
kubeServer := startKubernetes()
defer kubeServer.Shutdown()
restServer := startRest()
defer restServer.Shutdown()
logger.Log.Infoln("[MAIN] log-server ready!")
startSysCallChannel()
}
// startKubernetes -
func startKubernetes() *kubernetes.KubeServer {
server, err := kubernetes.NewKubeServer()
if err != nil {
logger.Log.Errorf("[MAIN] Kubernetes server creation failed: %s", err.Error())
os.Exit(404)
}
logger.Log.Debugln("[MAIN] Kubernetes server successfully created")
server.Start()
logger.Log.Debugln("[MAIN] Kubernetes successfully started")
return server
}
// startRest -
func startRest() *rest.RestServer {
server, err := rest.NewRestServer()
if err != nil {
logger.Log.Errorf("[MAIN] Echo server creation failed: %s", err.Error())
os.Exit(404)
}
logger.Log.Debugln("[MAIN] Echo server successfully created")
server.Start()
logger.Log.Debugln("[MAIN] Echo successfully started")
return server
}
// startSysCallChannel -
func startSysCallChannel() {
syscallCh := make(chan os.Signal)
signal.Notify(syscallCh, syscall.SIGTERM, syscall.SIGINT, os.Interrupt)
<-syscallCh
logger.Log.Warnln("[MAIN] Termination signal received!")
}