hpds_node/mq_windows.go

26 lines
614 B
Go
Raw Normal View History

2022-10-12 11:55:36 +08:00
//go:build windows
// +build windows
package hpds_node
import (
"git.hpds.cc/Component/network/log"
)
// initialize when mq running as server. support inspection:
// - `kill -SIGTERM <pid>` graceful shutdown
func (z *messageQueue) init() {
go func() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
2023-04-05 20:59:07 +08:00
log.Infof("%s Listening SIGTERM/SIGINT...", mqLogPrefix)
2022-10-12 11:55:36 +08:00
for p1 := range c {
log.Printf("Received signal: %s", p1)
if p1 == syscall.SIGTERM || p1 == syscall.SIGINT {
2023-04-05 20:59:07 +08:00
log.Infof("%s graceful shutting down ... %s", mqLogPrefix, p1)
2022-10-12 11:55:36 +08:00
os.Exit(0)
}
}
}()
}