2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-09-20 11:05:58 +08:00

Trap and handle TSTP signal

This commit is contained in:
Ken Hibino 2019-12-17 05:32:31 -08:00
parent 911e600c41
commit 3e30c5916b

View File

@ -77,8 +77,16 @@ func (bg *Background) Run(handler Handler) {
// Wait for a signal to terminate. // Wait for a signal to terminate.
sigs := make(chan os.Signal, 1) sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT) signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGTSTP)
<-sigs for {
sig := <-sigs
fmt.Printf("[DEBUG] Got %v\n", sig) // TODO: Remove this
if sig == syscall.SIGTSTP {
fmt.Println("[DEBUG] Stop processing tasks")
continue
}
break
}
fmt.Println() fmt.Println()
log.Println("[INFO] Starting graceful shutdown...") log.Println("[INFO] Starting graceful shutdown...")
} }