Created
March 7, 2012 17:13
-
-
Save funny-falcon/1994439 to your computer and use it in GitHub Desktop.
rainbows restart with inotifywait
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
export NGINX_DIR=../nginx | |
export LOG_DIR=$NGINX_DIR/log | |
export SOCK_DIR=$NGINX_DIR/socks | |
export APP=`basename "$(realpath "$(dirname "$0")")"` | |
PID_FILE=$SOCK_DIR/$APP.pid | |
if [ -e "$PID_FILE" ] ; then | |
PID=`cat $PID_FILE` | |
if [ -n `ps aux | awk '/rainbows/ && /$PID/ && !/awk/ {print $0}'` ] ; then | |
echo "Action: " $@ | |
if [ -n "$1" ] && [ "$1" != "kill" ] ; then | |
case $2 in | |
*.sw[op]) exit ;; | |
esac | |
kill -HUP $PID | |
exit | |
else | |
kill $PID | |
sleep 1 | |
fi | |
fi | |
fi | |
if [ -n "$1" ] ; then | |
exit | |
fi | |
rainbows -c serv_conf.rb -D | |
inotifywait -r -m . -e CREATE -e MODIFY -e DELETE | | |
grep -v -P '(.sw[op]|~|\s\d+)$' --line-buffered | | |
while read dir act file ; do | |
echo "LINE: $dir $act $file" | |
case $dir in | |
*/) | |
$0 $act "$dir$file" | |
;; | |
esac | |
done | |
$0 kill |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment