Skip to content

Commit 2d2fbad

Browse files
authored
Adding nginx config monitor script
1 parent b503e5d commit 2d2fbad

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/nginx_config_monitor.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
while true; do
4+
inotifywait --exclude .swp -e create -e modify -e delete -e move /etc/nginx/conf.d /etc/nginx/modules-enabled /etc/nginx/sites-enabled
5+
6+
# Test nginx config before attempting to restart.
7+
nginx -t
8+
if [ $? -eq 0 ]; then
9+
# Config test passed - loading config.
10+
echo "Detected Nginx Configuration Change"
11+
echo "Executing: nginx -s reload"
12+
nginx -s reload
13+
else
14+
echo "Config test did not pass. Please fix config and try again."
15+
fi
16+
done

0 commit comments

Comments
 (0)