Restart nginx on failure endlessly on Debian

Today my server experienced an outage and restarted automatically. However, my blog didn’t go online after that. With a little invesitgation it immediately got obvious that the nginx failed to start on first try of systemctl:

The root cause seemed to be a temporary outage of network, which led to failure in resolving r3.o.lencr.org. The network issue should automatically recover after a while, therefore so long as the system keeps retrying restarting nginx, the issue should have gone.

To let the system restart nginx endlessly, I follow the instructions here, and added the following to section [Service] of /lib/systemd/system/nginx.service:

Hopefully next time the same issue happens again things would recover seemlessly.

Leave a Reply

Your email address will not be published. Required fields are marked *