Files
upstream-centrifugo/internal/redisqueue/signals.go
upstream-mirror b352a9a30d
Some checks failed
test / Lint (push) Failing after 3s
test / Test with Go 1.26.8 (push) Failing after 2s
snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:17:21 +05:00

25 lines
490 B
Go

package redisqueue
import (
"os"
"os/signal"
"syscall"
)
// newSignalHandler registered for SIGTERM and SIGINT. A stop channel is
// returned which is closed on one of these signals. If a second signal is
// caught, the program is terminated with exit code 1.
func newSignalHandler() <-chan struct{} {
stop := make(chan struct{})
c := make(chan os.Signal, 2)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-c
close(stop)
<-c
os.Exit(1)
}()
return stop
}