feat: add the SIGINT signal in signals.go to subscribe the user input ctrl+c to exit the application operation (#3611)

master
#Suyghur 1 year ago committed by GitHub
parent d71c0da7b7
commit 95b7a3d3ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,7 +20,7 @@ func init() {
// https://golang.org/pkg/os/signal/#Notify
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGTERM)
signal.Notify(signals, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGTERM, syscall.SIGINT)
for {
v := <-signals
@ -34,14 +34,13 @@ func init() {
profiler.Stop()
profiler = nil
}
case syscall.SIGTERM:
case syscall.SIGTERM, syscall.SIGINT:
select {
case <-done:
// already closed
default:
close(done)
}
gracefulStop(signals)
default:
logx.Error("Got unregistered signal:", v)

Loading…
Cancel
Save