Fix service
This commit is contained in:
		| @@ -4,6 +4,7 @@ After=postgresql.service | |||||||
|  |  | ||||||
| [Service] | [Service] | ||||||
| Type=notify | Type=notify | ||||||
|  | WatchdogSec=10 | ||||||
| User=apiary | User=apiary | ||||||
| ExecStart=/usr/bin/apiary serve | ExecStart=/usr/bin/apiary serve | ||||||
| Restart=on-failure | Restart=on-failure | ||||||
|   | |||||||
| @@ -188,24 +188,16 @@ func ActionServe(c *cli.Context) error { | |||||||
| 		} | 		} | ||||||
| 		loggers.rootLogger.Debug("Sent READY=1 to NOTIFY_SOCKET.") | 		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 | 		// Setup timer | ||||||
| 		timeout, err := daemon.SdWatchdogEnabled(false) | 		timeout, err := daemon.SdWatchdogEnabled(false) | ||||||
| 		if err != nil { | 		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 | 			return | ||||||
| 		} | 		} | ||||||
| 		loggers.rootLogger.Debugw("Got invalid watchdog timeout", "timeout", timeout) |  | ||||||
|  |  | ||||||
| 		ticker := time.NewTicker(timeout / 2) | 		ticker := time.NewTicker(timeout / 2) | ||||||
| 		for { | 		for { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user