snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
24
internal/redisqueue/signals.go
Normal file
24
internal/redisqueue/signals.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user