You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/tool/kratos-gen-project/templates/http/cmd/main.go.tmpl

41 lines
783 B

package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"{{.ModPrefix}}{{.Name}}/internal/di"
"github.com/go-kratos/kratos/pkg/conf/paladin"
"github.com/go-kratos/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
}
}
}