小编Mat*_*t K的帖子

使用 OnFailure= 和 Restart= 混淆 systemd 行为

我在嵌入式系统中使用 systemd 231,并且我正在尝试创建一个服务来监视系统中的硬件组件。这是我正在尝试做的事情的粗略描述:

  1. 当服务 ,foo.service启动时,它会启动一个应用程序foo_app
  2. foo_app监控硬件组件,持续运行。
  3. 如果foo_app检测到硬件故障,它会以返回码 1 退出。这应该会触发系统重新启动。
  4. 如果foo_app崩溃,systemd 应该重新启动foo_app
  5. 如果foo_app 反复崩溃,systemd 应该重新启动系统。

这是我将其实现为服务的尝试:

[Unit]
Description=Foo Hardware Monitor

# If the application fails 3 times in 30 seconds, something has gone wrong,
# and the state of the hardware can't be guaranteed. Reboot the system here.
StartLimitBurst=3
StartLimitIntervalSec=30
StartLimitAction=reboot

# StartLimitAction=reboot will reboot the box if the app fails repeatedly,
# but if the app exits …
Run Code Online (Sandbox Code Playgroud)

systemd services

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

services ×1

systemd ×1