From d3c65cd7f86f7eb7c28a6a5c8d5b2bd03f9f22d0 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Fri, 23 Feb 2024 09:18:43 +0100 Subject: [PATCH] make nginx restart automatic on failure --- deployment/hetzner_cloud/install.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/deployment/hetzner_cloud/install.sh b/deployment/hetzner_cloud/install.sh index 06b92ecaf..b51f9b454 100755 --- a/deployment/hetzner_cloud/install.sh +++ b/deployment/hetzner_cloud/install.sh @@ -104,6 +104,23 @@ ln -s $SCRIPT_PATH/nginx/common /etc/nginx/ rmdir /etc/nginx/conf.d ln -s $SCRIPT_PATH/nginx/conf.d /etc/nginx/ +# Make nginx restart automatic +mkdir /etc/systemd/system/nginx.service.d +# Define the content to be put into the override.conf file +CONFIG_CONTENT="[Unit] +StartLimitIntervalSec=500 +StartLimitBurst=5 + +[Service] +Restart=on-failure +RestartSec=5s" + +# Write the content to the override.conf file +echo "$CONFIG_CONTENT" | sudo tee /etc/systemd/system/nginx.service.d/override.conf >/dev/null + +# Reload systemd to apply the changes +sudo systemctl daemon-reload + # setup https with certbot certbot certonly --nginx --non-interactive --agree-tos --domains $COMMUNITY_HOST --email $COMMUNITY_SUPPORT_MAIL