systemd: use constants and update status on ready (#1993)
Systemd-notify signaling indicates the status of dnscrypt-proxy when starting as 'Type=notify' systemd service. However, the status is not updated when initialization completes, instead it always shows "Starting". Now fixed.
This commit is contained in:
parent
06733f57ed
commit
7a8bd35009
|
@ -8,13 +8,15 @@ import (
|
||||||
clocksmith "github.com/jedisct1/go-clocksmith"
|
clocksmith "github.com/jedisct1/go-clocksmith"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const SdNotifyStatus = "STATUS="
|
||||||
|
|
||||||
func ServiceManagerStartNotify() error {
|
func ServiceManagerStartNotify() error {
|
||||||
daemon.SdNotify(false, "STATUS=Starting")
|
daemon.SdNotify(false, SdNotifyStatus+"Starting...")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServiceManagerReadyNotify() error {
|
func ServiceManagerReadyNotify() error {
|
||||||
daemon.SdNotify(false, "READY=1")
|
daemon.SdNotify(false, daemon.SdNotifyReady+"\n"+SdNotifyStatus+"Ready")
|
||||||
return systemDWatchdog()
|
return systemDWatchdog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +28,9 @@ func systemDWatchdog() error {
|
||||||
refreshInterval := watchdogFailureDelay / 3
|
refreshInterval := watchdogFailureDelay / 3
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
daemon.SdNotify(false, "WATCHDOG=1")
|
daemon.SdNotify(false, daemon.SdNotifyWatchdog)
|
||||||
clocksmith.Sleep(refreshInterval)
|
clocksmith.Sleep(refreshInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue