Configure Automatic Restart
Yesterday I experienced downtime on my NginX setup. I did a write up of the trouble shooting process, but one of the things I learned, which was also was actionable was configuring systemd to automatically restart my NginX in case of an incident like this.
The configuration file:
/etc/systemd/system/nginx.service
Can under the [Service] section have the following added:
Restart=always
RestartSec=5s
RestartSec defaults to: 100ms. Has to be configured with: Restart
I have no idea on how to test this at this time and I am still researching the root cause of the incident, but this was ready a nice extension to my configuration, which is just the default, since everything else is done it the site configuration for NginX.
Options for restart are:
noalwayson-successon-failureon-abnormalon-aborton-watchdog
The follow matrix lifted from systemd service man-page
| Exit causes/Restart settings | no |
always |
on-success |
on-failure |
on-abnormal |
on-abort |
on-watchdog |
|---|---|---|---|---|---|---|---|
| Clean exit code or signal | X | X | |||||
| Unclean exit code | X | X | |||||
| Unclean signal | X | X | X | X | |||
| Timeout | X | X | X | ||||
| Watchdog | X | X | X | X |