tl; dr: systemd 重新启动崩溃的服务数天,然后突然停止。
我有一个服务配置如下:
[Unit]
[Service]
Restart=always
RestartSec=2
StartLimitIntervalSec=0
ExecStart=/usr/local/bin/node --max-old-space-size=4096 /home/somewhere/something.js
StandardOutput=null
StandardError=null
KillMode=process
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
此代码有时会崩溃(每天 1-2 次),因此需要Restart=always. 然而,有时此服务不会重新启动,这是以下输出systemctl status:
Loaded: loaded (/home/somewhere/something-systemd.service; bad; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Mon 2017-12-04 10:10:46 CET; 7s ago
Process: 333 ExecStart=/usr/local/bin/node --max-old-space-size=4096 /home/somewhere/something.js (code=exited, status=1/FAILURE)
Main PID: 333 (code=exited, status=1/FAILURE)
Run Code Online (Sandbox Code Playgroud)
我的配置有错误吗?无论如何,我如何强制 systemd 重新启动服务?
systemd ×1