mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-27 00:12:31 +01:00
7a8bd35009
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.
37 lines
773 B
Go
37 lines
773 B
Go
//go:build !android
|
|
// +build !android
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/coreos/go-systemd/daemon"
|
|
clocksmith "github.com/jedisct1/go-clocksmith"
|
|
)
|
|
|
|
const SdNotifyStatus = "STATUS="
|
|
|
|
func ServiceManagerStartNotify() error {
|
|
daemon.SdNotify(false, SdNotifyStatus+"Starting...")
|
|
return nil
|
|
}
|
|
|
|
func ServiceManagerReadyNotify() error {
|
|
daemon.SdNotify(false, daemon.SdNotifyReady+"\n"+SdNotifyStatus+"Ready")
|
|
return systemDWatchdog()
|
|
}
|
|
|
|
func systemDWatchdog() error {
|
|
watchdogFailureDelay, err := daemon.SdWatchdogEnabled(false)
|
|
if err != nil || watchdogFailureDelay == 0 {
|
|
return err
|
|
}
|
|
refreshInterval := watchdogFailureDelay / 3
|
|
go func() {
|
|
for {
|
|
daemon.SdNotify(false, daemon.SdNotifyWatchdog)
|
|
clocksmith.Sleep(refreshInterval)
|
|
}
|
|
}()
|
|
return nil
|
|
}
|