Permalink
Browse files

Handle SIGTERM to exit cleanly

  • Loading branch information...
dlmiddlecote committed May 25, 2017
1 parent 2b9dd99 commit 5eae7957e545c730709673dc68647941f4870a14
Showing with 12 additions and 0 deletions.
  1. +12 −0 cmd/toxiproxy.go
View
@@ -3,6 +3,9 @@ package main
import (
"flag"
"math/rand"
"os"
"os/signal"
"syscall"
"time"
"github.com/Shopify/toxiproxy"
@@ -26,5 +29,14 @@ func main() {
if len(config) > 0 {
server.PopulateConfig(config)
}
// Handle SIGTERM to exit cleanly
signals := make(chan os.Signal)
signal.Notify(signals, syscall.SIGTERM)
go func() {
<-signals
os.Exit(0)
}()
server.Listen(host, port)
}

0 comments on commit 5eae795

Please sign in to comment.