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 重新启动服务?
StartLimitIntervalSec=
属于 [Unit] 部分。请参阅https://www.freedesktop.org/software/systemd/man/systemd.unit.html#
[单位] 部分选项
StartLimitIntervalSec=, StartLimitBurst=
配置单元启动速率限制。默认情况下,在 10 秒内启动超过 5 次的单元在 10 秒间隔结束之前不允许再启动。...
像这样:
[Unit]
StartLimitIntervalSec=0
[Service]
Restart=always
RestartSec=2
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)
归档时间: |
|
查看次数: |
2940 次 |
最近记录: |