1

Upon getting this type of error:

nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: core-dump) since Mon 2022-09-26 22:17:21 UTC; 8h ago
       Docs: man:nginx(8)

there was an attempt to monitor and restart nginx when it would fail. Yet, different syntassi are proposed in various sources:

Restart=always
Restart=on-failure

The documentation for either the timers or the units do not describe this parameter. Which also creates uncertainty as to what is the default timer and whether it should be specifically set.

The nginx.service file was edited to include one, then the other from directory /usr/lib/systemd/system.
Interestingly, directory /lib/systemd/system has the same file (and neither is indicated as an alias; I assume a directory alias is in play?) and a change to one is reflected on the other.
All changes were followed up by a systemctl daemon-reload

The change did not restart nginx as expected. Thus:

  • what is the difference between these two syntassi
  • what timer is applied by default if none is specified
muru
  • 72,889
Jerome
  • 139
  • "Interestingly, directory /lib/systemd/system has the same file" Look up "usr merge": https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/ https://wiki.debian.org/UsrMerge – muru Sep 27 '22 at 09:58

1 Answers1

1

There’s an index for all systemd directives in man systemd.directives; for Restart=, this leads to man systemd.service.

Restart= determines what should happen when the managed service exits. on-failure specifies that it should be restarted if it exits with a non-zero exit code, because of a signal, or if a management operation times out. always specifies that it should be restarted in all cases.

There is no monitoring timeout here, the process is restarted when it exits. Services can be configured with a watchdog, but that requires cooperation from the managed service (it needs to periodically notify the watchdog).

Stephen Kitt
  • 434,908