2021-09-23 19:16:26 +02:00
|
|
|
//go:build !android
|
2019-10-03 16:11:02 +02:00
|
|
|
// +build !android
|
|
|
|
|
2018-07-19 19:03:57 +02:00
|
|
|
package main
|
|
|
|
|
2019-10-03 14:39:09 +02:00
|
|
|
import (
|
|
|
|
"github.com/coreos/go-systemd/daemon"
|
|
|
|
clocksmith "github.com/jedisct1/go-clocksmith"
|
|
|
|
)
|
2018-07-19 19:03:57 +02:00
|
|
|
|
2022-01-19 20:30:15 +01:00
|
|
|
const SdNotifyStatus = "STATUS="
|
|
|
|
|
2018-07-19 19:03:57 +02:00
|
|
|
func ServiceManagerStartNotify() error {
|
2022-01-19 20:30:15 +01:00
|
|
|
daemon.SdNotify(false, SdNotifyStatus+"Starting...")
|
2018-07-19 19:03:57 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-10-03 14:39:09 +02:00
|
|
|
func ServiceManagerReadyNotify() error {
|
2022-01-19 20:30:15 +01:00
|
|
|
daemon.SdNotify(false, daemon.SdNotifyReady+"\n"+SdNotifyStatus+"Ready")
|
2019-10-03 14:39:09 +02:00
|
|
|
return systemDWatchdog()
|
|
|
|
}
|
|
|
|
|
|
|
|
func systemDWatchdog() error {
|
|
|
|
watchdogFailureDelay, err := daemon.SdWatchdogEnabled(false)
|
|
|
|
if err != nil || watchdogFailureDelay == 0 {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
refreshInterval := watchdogFailureDelay / 3
|
|
|
|
go func() {
|
|
|
|
for {
|
2022-01-19 20:30:15 +01:00
|
|
|
daemon.SdNotify(false, daemon.SdNotifyWatchdog)
|
2019-10-03 14:39:09 +02:00
|
|
|
clocksmith.Sleep(refreshInterval)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
return nil
|
2018-07-19 19:03:57 +02:00
|
|
|
}
|