Skip to content

Commit

Permalink
Merge pull request #672 from dmitri-zganiaiko/graceful-shutdown-on-si…
Browse files Browse the repository at this point in the history
…gterm

Add graceful shutdown on SIGTERM
  • Loading branch information
tidwall authored May 6, 2023
2 parents 4a9ebf4 + aa1060a commit 65f0370
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/tile38-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ Developer Options:
}

c := make(chan os.Signal, 1)
shutdown := make (chan bool, 1)

signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
Expand All @@ -433,7 +434,7 @@ Developer Options:
case s == syscall.SIGQUIT:
os.Exit(3)
case s == syscall.SIGTERM:
os.Exit(0xf)
shutdown <- true
}
}
}()
Expand Down Expand Up @@ -481,6 +482,7 @@ Developer Options:
AppendOnly: appendOnly,
AppendFileName: appendFileName,
QueueFileName: queueFileName,
Shutdown: shutdown,
}
if err := server.Serve(opts); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 65f0370

Please sign in to comment.