From 7a8bd350093b9a7c2c3b61744b1eb04bbea02ee4 Mon Sep 17 00:00:00 2001 From: cobratbq <1936470+cobratbq@users.noreply.github.com> Date: Wed, 19 Jan 2022 20:30:15 +0100 Subject: [PATCH] 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. --- dnscrypt-proxy/service_linux.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dnscrypt-proxy/service_linux.go b/dnscrypt-proxy/service_linux.go index 9851f8da..878a56ae 100644 --- a/dnscrypt-proxy/service_linux.go +++ b/dnscrypt-proxy/service_linux.go @@ -8,13 +8,15 @@ import ( clocksmith "github.com/jedisct1/go-clocksmith" ) +const SdNotifyStatus = "STATUS=" + func ServiceManagerStartNotify() error { - daemon.SdNotify(false, "STATUS=Starting") + daemon.SdNotify(false, SdNotifyStatus+"Starting...") return nil } func ServiceManagerReadyNotify() error { - daemon.SdNotify(false, "READY=1") + daemon.SdNotify(false, daemon.SdNotifyReady+"\n"+SdNotifyStatus+"Ready") return systemDWatchdog() } @@ -26,10 +28,9 @@ func systemDWatchdog() error { refreshInterval := watchdogFailureDelay / 3 go func() { for { - daemon.SdNotify(false, "WATCHDOG=1") + daemon.SdNotify(false, daemon.SdNotifyWatchdog) clocksmith.Sleep(refreshInterval) } - }() return nil }