Skip to content

Commit

Permalink
feat(log): add logfile for nginx reload service
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jun 8, 2024
1 parent 2ae4399 commit eafa765
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions nginx/watch_reload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +24,6 @@ watch_reloads () {
fi
}

watch_reloads &
watch_reloads >/nginx_auto_reload_service.log 2>&1 &

nginx -g 'daemon off;'
nginx -g 'daemon off;'

0 comments on commit eafa765

Please sign in to comment.