Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Created March 24, 2014 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save szepeviktor/9743647 to your computer and use it in GitHub Desktop.
Save szepeviktor/9743647 to your computer and use it in GitHub Desktop.
Auto reload NGINX by incron (inotify cron)
/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
#!/bin/sh
error() {
local RET=$1
shift
echo -e "$@" >&2
exit "$RET"
}
sleep 5
service nginx reload || error 2 "nginx reload error"
#!/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