我在嵌入式系统中使用 systemd 231,并且我正在尝试创建一个服务来监视系统中的硬件组件。这是我正在尝试做的事情的粗略描述:
foo.service
启动时,它会启动一个应用程序foo_app
。foo_app
监控硬件组件,持续运行。foo_app
检测到硬件故障,它会以返回码 1 退出。这应该会触发系统重新启动。foo_app
崩溃,systemd 应该重新启动foo_app
。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)