From 19724367dfb3c56e72124b9830b9d5793911b009 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 18 Mar 2024 21:45:02 +0530 Subject: [PATCH] Support nginx configuration reloads --- infra/services/nginx/README.md | 7 ++++--- infra/services/nginx/nginx.service | 2 ++ infra/services/status/README.md | 4 ++-- server/scripts/deploy/README.md | 2 +- server/scripts/deploy/museum.nginx.service | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/infra/services/nginx/README.md b/infra/services/nginx/README.md index 75c2c7798..7239a5610 100644 --- a/infra/services/nginx/README.md +++ b/infra/services/nginx/README.md @@ -2,7 +2,7 @@ This is a base Nginx service that terminates TLS, and can be used as a reverse proxy for arbitrary services by adding new entries in `/root/nginx/conf.d` and -`sudo systemctl restart nginx`. +`sudo systemctl reload nginx`. ## Installation @@ -41,7 +41,7 @@ When adding new services that sit behind Nginx, 1. Add its nginx conf file to `/root/nginx/conf.d` -2. Restart nginx (`sudo systemctl restart nginx`) +2. Restart nginx (`sudo systemctl reload nginx`) ## Configuration files @@ -60,4 +60,5 @@ We can see this in the default configuration of nginx: > docker run --rm --entrypoint=cat nginx /etc/nginx/nginx.conf > /tmp/nginx.conf This is a [handy tool](https://nginx-playground.wizardzines.com) to check the -syntax of the configuration files. +syntax of the configuration files. Alternatively, you can run `docker exec nginx +nginx -t` on the instance to ask nginx to check the configuration. diff --git a/infra/services/nginx/nginx.service b/infra/services/nginx/nginx.service index 4f772d38d..958bb6e06 100644 --- a/infra/services/nginx/nginx.service +++ b/infra/services/nginx/nginx.service @@ -2,6 +2,7 @@ Documentation=https://www.docker.com/blog/how-to-use-the-official-nginx-docker-image/ Requires=docker.service After=docker.service +Requires=nginx.service [Install] WantedBy=multi-user.target @@ -17,3 +18,4 @@ ExecStart=docker run --name nginx \ -v /root/nginx/key.pem:/etc/ssl/private/key.pem:ro \ -v /root/nginx/conf.d:/etc/nginx/conf.d:ro \ nginx +ExecReload=docker exec nginx nginx -s reload diff --git a/infra/services/status/README.md b/infra/services/status/README.md index 51166f424..d2e4b55e3 100644 --- a/infra/services/status/README.md +++ b/infra/services/status/README.md @@ -32,8 +32,8 @@ sudo systemctl daemon-reload sudo systemctl enable --now uptime-kuma ``` -Restart nginx +Tell nginx to pick up the new configuration. ```sh -sudo systemctl restart nginx +sudo systemctl reload nginx ``` diff --git a/server/scripts/deploy/README.md b/server/scripts/deploy/README.md index 04d121210..35e1ec079 100644 --- a/server/scripts/deploy/README.md +++ b/server/scripts/deploy/README.md @@ -87,7 +87,7 @@ To bring up an additional museum node: scp scripts/deploy/museum.nginx.conf : sudo mv museum.nginx.conf /root/nginx/conf.d - sudo systemctl restart nginx + sudo systemctl reload nginx ## Starting diff --git a/server/scripts/deploy/museum.nginx.service b/server/scripts/deploy/museum.nginx.service index 73cdd3ff1..566c6c048 100644 --- a/server/scripts/deploy/museum.nginx.service +++ b/server/scripts/deploy/museum.nginx.service @@ -2,6 +2,7 @@ Documentation=https://github.com/ente-io/ente/tree/main/server#readme Requires=docker.service After=docker.service +Requires=nginx.service [Service] Restart=on-failure