Fix service
This commit is contained in:
parent
631bec38d0
commit
ed66cd5492
@ -4,6 +4,7 @@ After=postgresql.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
WatchdogSec=10
|
||||
User=apiary
|
||||
ExecStart=/usr/bin/apiary serve
|
||||
Restart=on-failure
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user