Restart nginx on failure endlessly on DebianToday 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
:
1234567 Jun 20 00:00:51 systemd[1]: Starting A high performance web server and a reverse proxy server...Jun 20 00:00:33 nginx[814]: nginx: [warn] "ssl_stapling" ignored, host not found in OCSP responder "r3.o.lencr.org" in the certificate ">Jun 20 00:00:14 nginx[814]: nginx: [warn] "ssl_stapling" ignored, host not found in OCSP responder "r3.o.lencr.org" in the certificate ">Jun 20 00:00:21 systemd[1]: nginx.service: start-pre operation timed out. Terminating.Jun 20 00:00:21 systemd[1]: nginx.service: Control process exited, code=killed, status=15/TERMJun 20 00:00:21 systemd[1]: nginx.service: Failed with result 'timeout'.Jun 20 00:00:21 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
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
:
123 # In section [Service]Restart=alwaysRestartSec=10
Hopefully next time the same issue happens again things would recover seemlessly.
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
:
1 2 3 4 5 6 7 | Jun 20 00:00:51 systemd[1]: Starting A high performance web server and a reverse proxy server... Jun 20 00:00:33 nginx[814]: nginx: [warn] "ssl_stapling" ignored, host not found in OCSP responder "r3.o.lencr.org" in the certificate "> Jun 20 00:00:14 nginx[814]: nginx: [warn] "ssl_stapling" ignored, host not found in OCSP responder "r3.o.lencr.org" in the certificate "> Jun 20 00:00:21 systemd[1]: nginx.service: start-pre operation timed out. Terminating. Jun 20 00:00:21 systemd[1]: nginx.service: Control process exited, code=killed, status=15/TERM Jun 20 00:00:21 systemd[1]: nginx.service: Failed with result 'timeout'. Jun 20 00:00:21 systemd[1]: Failed to start A high performance web server and a reverse proxy server. |
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
:
1 2 3 | # In section [Service] Restart=always RestartSec=10 |
Hopefully next time the same issue happens again things would recover seemlessly.