Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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