Hello author.
Is it true that graceful shutdown does not work on Windows platform? I found the corresponding logic in Linux or Darwin in the code.
My scenario is on Windows platform. I hope that when receiving the termination signal, the cached log will be saved to the file before exiting. But in fact, the program is terminated immediately.
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
server := rest.MustNewServer(c.RestConf, rest.WithCors())
Init()
server.Use(middleware.AuthInterceptor)
server.Use(middleware.GlobalExceptionMiddleware)
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
group := service.NewServiceGroup()
defer group.Stop()
group.Add(&ws.WebSocketService{})
group.Add(server)
logx.Info("Starting http server at:", c.Host, c.Port)
waitForCalled := proc.AddShutdownListener(func() {
// ...save cached logs to file before exiting
})
group.Start()
waitForCalled()
}
Hello author. Is it true that graceful shutdown does not work on Windows platform? I found the corresponding logic in Linux or Darwin in the code.
My scenario is on Windows platform. I hope that when receiving the termination signal, the cached log will be saved to the file before exiting. But in fact, the program is terminated immediately.
Looking forward to your reply, thank you