-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
60 lines (46 loc) · 1.02 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
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/redcraft-org/redcraft_server_management/rcsm"
)
func main() {
initialize()
waitForQuitSignal()
stop()
}
func initialize() {
if rcsm.ReadEnvBool("DUMP_VERSION_AND_EXIT", false) {
fmt.Print(rcsm.Version)
os.Exit(0)
}
rcsm.ReadConfig()
rcsm.TriggerLogEvent("info", "rcsm", fmt.Sprintf("Starting rcsm (RedCraft Server Manager) v%s", rcsm.Version))
if rcsm.RedisEnabled {
rcsm.RedisConnect()
}
rcsm.CreateMissingServers()
rcsm.DiscoverServers()
if rcsm.AutoStartOnBoot {
rcsm.StartAllServers()
}
if rcsm.AutoRestartCrashEnabled {
rcsm.StartHealthCheck()
}
if rcsm.AutoUpdateEnabled {
rcsm.StartUpdateChecks()
}
}
func stop() {
rcsm.TriggerLogEvent("info", "rcsm", fmt.Sprintf("Stopping rcsm (RedCraft Server Manager) v%s", rcsm.Version))
if rcsm.AutoStopOnClose {
rcsm.StopAllServers()
}
}
func waitForQuitSignal() {
exitSignal := make(chan os.Signal)
signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM)
<-exitSignal
}