From eafa76521a8575bad90a52716bc98df751fe7b33 Mon Sep 17 00:00:00 2001 From: proffapt Date: Sat, 8 Jun 2024 13:27:34 +0530 Subject: [PATCH] feat(log): add logfile for nginx reload service --- nginx/watch_reload.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/nginx/watch_reload.sh b/nginx/watch_reload.sh index fd37d4d..5e43582 100755 --- a/nginx/watch_reload.sh +++ b/nginx/watch_reload.sh @@ -3,20 +3,15 @@ # Thanks to https://cyral.com/blog/how-to-auto-reload-nginx/ -watch_reloads () { - if [[ $(command -v inotifywait) != "" ]]; - then - while true - do +watch_reloads() { + if [[ $(command -v inotifywait) != "" ]]; then + while true; do inotifywait --exclude .swp -e create -e modify -e delete -e move /etc/nginx/sites-enabled/ echo "Detected Nginx configuration change." - # Tests the new configuration - nginx -t - - if [ $? -eq 0 ] - then + # Test and reload the new configuration + if nginx -t; then echo "Configuration OK. Executing: nginx -s reload" nginx -s reload else @@ -29,6 +24,6 @@ watch_reloads () { fi } -watch_reloads & +watch_reloads >/nginx_auto_reload_service.log 2>&1 & -nginx -g 'daemon off;' \ No newline at end of file +nginx -g 'daemon off;'