Merge PR #65: Tell servers to Stop when shutting down.

This commit is contained in:
Davide Beatrici 2020-04-13 01:17:05 +02:00 committed by GitHub
commit cf3885170e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ package main
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
@ -27,6 +28,14 @@ func SignalHandler() {
continue continue
} }
if sig == syscall.SIGINT || sig == syscall.SIGTERM { if sig == syscall.SIGINT || sig == syscall.SIGTERM {
for _, server := range servers {
log.Printf("Stopping server %v", server.Id)
err := server.Stop()
if err != nil {
log.Printf("Server err %v", err)
}
}
log.Print("All servers stopped. Exiting.")
os.Exit(0) os.Exit(0)
} }
} }