-
-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] kill -TERM pid the process still exists #78
Comments
@cielu Did you manage to resolve the issue? |
@hibiken Thank you ! I have resolve the issue . I know the reason about can't kill that process . Asynq have own graceful shut down way , but the Gin framework don't asynq : // Wait for a signal to terminate.
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGTSTP)
for {
sig := <-sigs
if sig == syscall.SIGTSTP {
bg.processor.stop()
bg.pinfo.SetState("stopped")
continue
}
break
} so , if I want them work together , Gin should graceful shut down too (receive the signal to exit). // Init router
router := routes.InitRouter()
srv := &http.Server{
Addr: ":" + setting.AppCfg.AppPort,
Handler: router,
}
/
go func() {
// service connections
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatalf("listen: %s\n", err)
}
}()
// Wait for interrupt signal to gracefully shutdown the server
quit := make(chan os.Signal)
// kill (no param) default send syscanll.SIGTERM
// kill -2 is syscall.SIGINT
// kill -9 is syscall. SIGKILL but can"t be catch, so don't need add it
signal.Notify(quit, os.Interrupt)
<-quit
log.Println("Shutdown Server ...")
//
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
//
if err := srv.Shutdown(ctx); err != nil {
log.Fatal("Server Shutdown:", err)
}
log.Println("Server exiting") But it is still recommend to separate the asynq workers |
Glad that you were able to resolve the issue. This was a useful feedback, maybe I can export Thanks for creating the issues! |
Haha,Look forward to version 1.0 |
mac os .
I don't know if this is a bug .
The process could only kill by kill -9
The text was updated successfully, but these errors were encountered: