Report "reloading" state to systemd when running reload callbacks

This commit is contained in:
fox.cpp 2020-01-02 12:37:35 +03:00
parent ea40a8fbc5
commit 24a580a338
No known key found for this signature in database
GPG key ID: E76D97CCEDE90B6C
3 changed files with 10 additions and 4 deletions

View file

@ -25,10 +25,14 @@ func handleSignals() os.Signal {
switch s := <-sig; s { switch s := <-sig; s {
case syscall.SIGUSR1: case syscall.SIGUSR1:
log.Printf("signal received (%s), rotating logs", s.String()) log.Printf("signal received (%s), rotating logs", s.String())
systemdStatus(SDReloading, "Reopening logs...")
hooks.RunHooks(hooks.EventLogRotate) hooks.RunHooks(hooks.EventLogRotate)
systemdStatus(SDReady, "Listening for incoming connections...")
case syscall.SIGUSR2: case syscall.SIGUSR2:
log.Printf("signal received (%s), reloading state", s.String()) log.Printf("signal received (%s), reloading state", s.String())
systemdStatus(SDReloading, "Reloading state...")
hooks.RunHooks(hooks.EventReload) hooks.RunHooks(hooks.EventReload)
systemdStatus(SDReady, "Listening for incoming connections...")
default: default:
go func() { go func() {
s := handleSignals() s := handleSignals()

View file

@ -18,6 +18,7 @@ type SDStatus string
const ( const (
SDReady = "READY=1" SDReady = "READY=1"
SDReloading = "RELOADING=1"
SDStopping = "STOPPING=1" SDStopping = "STOPPING=1"
) )

View file

@ -6,6 +6,7 @@ type SDStatus string
const ( const (
SDReady = "READY=1" SDReady = "READY=1"
SDReloading = "RELOADING=1"
SDStopping = "STOPPING=1" SDStopping = "STOPPING=1"
) )