stop DNS server properly when interrupted with ctrl+c, SIGTERM, SIGHUP or SIGQUIT

This commit is contained in:
Eugene Bujak
2018-12-05 15:36:18 +03:00
parent b0149972cc
commit 7ddc71006b
2 changed files with 29 additions and 4 deletions

View File

@@ -74,3 +74,16 @@ func reconfigureDNSServer() error {
return nil
}
func stopDNSServer() error {
if !isRunning() {
return fmt.Errorf("Refusing to stop forwarding DNS server: not running")
}
err := dnsServer.Stop()
if err != nil {
return errorx.Decorate(err, "Couldn't stop forwarding DNS server")
}
return nil
}