mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
Tell servers to Stop when shutting down.
Run Stop() on all the server when a SIGINT or SIGTERM is received. This should ensure any open sockets and files are closed.
This commit is contained in:
parent
12775db8ce
commit
68453fa6d6
1 changed files with 9 additions and 0 deletions
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue