Skip to content

Commit

Permalink
Don't fork during shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
nikmolnar committed May 10, 2019
1 parent 06610ae commit 76cd5ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func supervise() {
}

var child *exec.Cmd = nil
shutdown := false

// Graceful shutdown on Ctrl + C
go func() {
Expand All @@ -312,6 +313,7 @@ func supervise() {

<-interrupt

shutdown = true
fmt.Println("\nShutting down...")

if child != nil {
Expand All @@ -321,6 +323,10 @@ func supervise() {
}()

for {
if shutdown {
break
}

hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)

Expand Down

0 comments on commit 76cd5ad

Please sign in to comment.