feat: add the SIGINT signal in signals.go to subscribe the user input ctrl+c to exit the application operation (#3611)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user