This commit is contained in:
lu.bai
2022-11-24 23:29:33 +08:00
parent 71d0135d6f
commit 48d5291b33
18 changed files with 445 additions and 191 deletions

View File

@@ -1,38 +1,23 @@
package main
import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"time"
"hk4e/common/config"
"hk4e/gm/controller"
"hk4e/pkg/logger"
"hk4e/gm/app"
)
var (
config = flag.String("config", "application.toml", "config file")
)
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
}
flag.Parse()
err := app.Run(context.TODO(), *config)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}