-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (37 loc) · 905 Bytes
/
main.go
File metadata and controls
49 lines (37 loc) · 905 Bytes
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
package main
import (
"os"
"os/signal"
"syscall"
"github.com/panelmc/daemon/api"
"github.com/panelmc/daemon/daemon"
"github.com/panelmc/daemon/infra"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var exitChan = make(chan os.Signal, 1)
var rootCmd = &cobra.Command{
Use: "panelmc",
Short: "Starts the daemon master node",
Run: func(cmd *cobra.Command, args []string) {
run()
},
}
func main() {
infra.InitializeLogger()
infra.InitializeCommand()
infra.ServerConfig(rootCmd)
if err := rootCmd.Execute(); err != nil {
logrus.WithError(err).Fatal()
}
}
func run() {
signal.Notify(exitChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
daemon.Init()
server := infra.NewServer(8080, infra.DebugMode)
api.Init(server)
daemon.Start()
<-exitChan
logrus.Infoln("Closing the daemon...")
logrus.Exit(1)
}