Skip to content

Commit

Permalink
feat: add the SIGINT signal in signals.go to listen for the user ente…
Browse files Browse the repository at this point in the history
…r ctrl+c to exit the application operation
  • Loading branch information
Suyghur authored and kevwan committed Oct 15, 2023
1 parent 4f22034 commit bc9b5ab
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/proc/signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit bc9b5ab

Please sign in to comment.