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.
41 lines
769 B
41 lines
769 B
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("abc 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("abc exit")
|
|
time.Sleep(time.Second)
|
|
return
|
|
case syscall.SIGHUP:
|
|
default:
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|