1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2024-12-28 00:20:13 +01:00
dnscrypt-proxy/dnscrypt-proxy/service_linux.go

37 lines
773 B
Go
Raw Normal View History

2021-09-23 19:16:26 +02:00
//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
}