Skip to content
Open
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
10 changes: 9 additions & 1 deletion go/cmd/gh-ost/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var AppVersion, GitCommit string
func acceptSignals(migrationContext *base.MigrationContext) {
c := make(chan os.Signal, 1)

signal.Notify(c, syscall.SIGHUP)
signal.Notify(c, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT)
go func() {
for sig := range c {
switch sig {
Expand All @@ -40,6 +40,14 @@ func acceptSignals(migrationContext *base.MigrationContext) {
} else {
migrationContext.MarkPointOfInterest()
}
case syscall.SIGTERM, syscall.SIGINT:
migrationContext.Log.Infof("Received %s. Initiating graceful shutdown", sig)
select {
case migrationContext.PanicAbort <- fmt.Errorf("received signal: %s", sig):
default:
migrationContext.Log.Errorf("failed to send abort signal, forcing exit")
os.Exit(1)
}
}
}
}()
Expand Down
Loading