-
Notifications
You must be signed in to change notification settings - Fork 1
signals
Tony edited this page Jul 6, 2022
·
2 revisions
通过发送 TERM 或 INT 信号可非强杀方式(gracefully shutdown)关停队列消费者。
kill -TERM <pid> # 关停队列消费者
可结合 giant-stone/go/gracequit 包快速实现通用服务端进程信号处理
import (
"github.com/giant-stone/go/gracequit"
)
// ...
quitAfterSecs := 2
gq := gracequit.New(
"path/to/pid",
quitAfterSecs,
)
gq.FuncCallBeforeQuit = myDeadwordsFunc
ctx := gq.Init()
srv := gmq.NewServer(ctx)
// ...