package main import ( "flag" "os" "os/signal" "syscall" "time" "{{.ModPrefix}}{{.Name}}/internal/di" "github.com/bilibili/kratos/pkg/conf/paladin" "github.com/bilibili/kratos/pkg/log" ) func main() { flag.Parse() log.Init(nil) // debug flag: log.dir={path} defer log.Close() log.Info("{{.Name}} start") paladin.Init() _, closeFunc, err := di.InitApp() if err != nil { panic(err) } c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) for { s := <-c log.Info("get a signal %s", s.String()) switch s { case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT: closeFunc() log.Info("{{.Name}} exit") time.Sleep(time.Second) return case syscall.SIGHUP: default: return } } }