mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Trap and handle TSTP signal
This commit is contained in:
parent
911e600c41
commit
3e30c5916b
@ -77,8 +77,16 @@ func (bg *Background) Run(handler Handler) {
|
||||
|
||||
// Wait for a signal to terminate.
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT)
|
||||
<-sigs
|
||||
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGTSTP)
|
||||
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()
|
||||
log.Println("[INFO] Starting graceful shutdown...")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user