Created
March 24, 2014 16:22
-
-
Save szepeviktor/9743647 to your computer and use it in GitHub Desktop.
Auto reload NGINX by incron (inotify cron)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/var/www/site1/nginx.conf IN_MODIFY,IN_NO_LOOP /usr/local/sbin/nginx-reload.sh | |
/var/www/site2/nginx.conf IN_MODIFY,IN_NO_LOOP /usr/local/sbin/nginx-reload.sh | |
/var/www/site3/nginx.conf IN_MODIFY,IN_NO_LOOP /usr/local/sbin/nginx-reload.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
error() { | |
local RET=$1 | |
shift | |
echo -e "$@" >&2 | |
exit "$RET" | |
} | |
sleep 5 | |
service nginx reload || error 2 "nginx reload error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
flock -x "/var/lock/nginx-reload" -c nginx-reload-worker.sh | |
logger -t "nginx-reload[$$]" "Reloading OK" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment