From ed66cd54922acb13308bd1c840403323b9b7dfca Mon Sep 17 00:00:00 2001 From: = Date: Sat, 6 Nov 2021 01:59:21 +0100 Subject: [PATCH] Fix service --- apiary.service | 1 + cmd/apiary.go | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/apiary.service b/apiary.service index 395437b..8d4bdd9 100644 --- a/apiary.service +++ b/apiary.service @@ -4,6 +4,7 @@ After=postgresql.service [Service] Type=notify +WatchdogSec=10 User=apiary ExecStart=/usr/bin/apiary serve Restart=on-failure diff --git a/cmd/apiary.go b/cmd/apiary.go index 7647029..3a6970f 100644 --- a/cmd/apiary.go +++ b/cmd/apiary.go @@ -188,24 +188,16 @@ func ActionServe(c *cli.Context) error { } loggers.rootLogger.Debug("Sent READY=1 to NOTIFY_SOCKET.") - if _, err := daemon.SdNotify(false, "WATCHDOG_USEC=10000000"); err != nil { - loggers.rootLogger.Warnw("Unable to connect to NOTIFY_SOCKET to set watchdog timeout.", "error", err) - return - } - loggers.rootLogger.Debug("Sent WATCHDOG_USEC=10000000 to NOTIFY_SOCKET.") - if _, err := daemon.SdNotify(false, daemon.SdNotifyWatchdog); err != nil { - loggers.rootLogger.Warnw("Unable to connect to NOTIFY_SOCKET to notify watchdog.", "error", err) - return - } - loggers.rootLogger.Debug("Sent WATCHDOG=1 to NOTIFY_SOCKET.") - // Setup timer timeout, err := daemon.SdWatchdogEnabled(false) if err != nil { - loggers.rootLogger.Warnw("Unable to connect to NOTIFY_SOCKET to get watchdog timeout.", "error", err) + loggers.rootLogger.Warnw("Unable to get watchdog timeout.", "error", err) + return + } + if timeout == 0 { + loggers.rootLogger.Infow("Systemd watchdog not enabled.") return } - loggers.rootLogger.Debugw("Got invalid watchdog timeout", "timeout", timeout) ticker := time.NewTicker(timeout / 2) for {