tl;dr: systemd restarts a crashing service for days and then suddenly stops.
I've got a service configured as follows:
[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
This code crashes sometimes (1-2 times a day), hence the need to Restart=always
. Yet once in a while this service doesn't get restarted and here's the output of 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)
Is there a mistake in my configuration? How do I force systemd to restart a service no matter what?
Best Answer
StartLimitIntervalSec=
belongs to the [Unit] section. See https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Like this: