mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:32:26 +08:00
refactor
This commit is contained in:
12
cmd/gm/application.toml
Normal file
12
cmd/gm/application.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
http_port = 9001
|
||||
|
||||
[logger]
|
||||
level = "DEBUG"
|
||||
method = "CONSOLE"
|
||||
track_line = true
|
||||
|
||||
[database]
|
||||
url = "mongodb://mongo:27017"
|
||||
|
||||
[mq]
|
||||
nats_url = "nats://nats1:4222,nats://nats2:4222,nats://nats3:4222"
|
||||
38
cmd/gm/main.go
Normal file
38
cmd/gm/main.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"hk4e/common/config"
|
||||
"hk4e/gm/controller"
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
filePath := "./application.toml"
|
||||
config.InitConfig(filePath)
|
||||
|
||||
logger.InitLogger("gm", config.CONF.Logger)
|
||||
logger.LOG.Info("gm start")
|
||||
|
||||
_ = controller.NewController()
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
|
||||
for {
|
||||
s := <-c
|
||||
logger.LOG.Info("get a signal %s", s.String())
|
||||
switch s {
|
||||
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
|
||||
logger.LOG.Info("gm exit")
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user