Skip to content

Commit 7a8bd35

Browse files
authored
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.
1 parent 06733f5 commit 7a8bd35

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

dnscrypt-proxy/service_linux.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import (
88
clocksmith "github.com/jedisct1/go-clocksmith"
99
)
1010

11+
const SdNotifyStatus = "STATUS="
12+
1113
func ServiceManagerStartNotify() error {
12-
daemon.SdNotify(false, "STATUS=Starting")
14+
daemon.SdNotify(false, SdNotifyStatus+"Starting...")
1315
return nil
1416
}
1517

1618
func ServiceManagerReadyNotify() error {
17-
daemon.SdNotify(false, "READY=1")
19+
daemon.SdNotify(false, daemon.SdNotifyReady+"\n"+SdNotifyStatus+"Ready")
1820
return systemDWatchdog()
1921
}
2022

@@ -26,10 +28,9 @@ func systemDWatchdog() error {
2628
refreshInterval := watchdogFailureDelay / 3
2729
go func() {
2830
for {
29-
daemon.SdNotify(false, "WATCHDOG=1")
31+
daemon.SdNotify(false, daemon.SdNotifyWatchdog)
3032
clocksmith.Sleep(refreshInterval)
3133
}
32-
3334
}()
3435
return nil
3536
}

0 commit comments

Comments
 (0)