1
0
Fork 0
mirror of https://github.com/foxcpp/maddy.git synced 2025-04-05 05:57:39 +03:00
maddy/signal_nonposix.go
fox.cpp 974dd3c7f8
Use systemd notify socket to report process status
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.
2019-11-21 23:58:06 +03:00

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
}