mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-05 05:57:39 +03:00
It has all sorts of benefits due to the service manager being aware of the starting/running/stopping state, see systemd.service(5) On top of that, start-up errors are reported using STATUS= key, so they will be easier to see in the 'systemctl status' output.
26 lines
473 B
Go
26 lines
473 B
Go
//+build windows
|
|
|
|
package maddy
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/foxcpp/maddy/log"
|
|
)
|
|
|
|
func handleSignals() os.Signal {
|
|
sig := make(chan os.Signal, 5)
|
|
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGINT)
|
|
|
|
s := <-sig
|
|
go func() {
|
|
s := handleSignals()
|
|
log.Printf("forced shutdown due to signal (%v)!", s)
|
|
os.Exit(1)
|
|
}()
|
|
|
|
log.Printf("signal received (%v), next signal will force immediate shutdown.", s)
|
|
return s
|
|
}
|