Last active
February 29, 2016 12:31
-
-
Save stengland/76826150c116cf69f5ed to your computer and use it in GitHub Desktop.
Simple wrapper around rackup that restarts Rack when files change (uses inotify-tools' inotifywait)
This file contains hidden or 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 | |
trap Terminate SIGINT SIGTERM SIGQUIT SIGKILL | |
Start () { | |
echo "Starting rack..." | |
rackup $@ & | |
echo $! > /tmp/rerackup.pid | |
} | |
Stop () { | |
echo "Stopping rack..." | |
kill `cat /tmp/rerackup.pid` | |
rm /tmp/rerackup.pid | |
} | |
Terminate () { | |
Stop | |
echo "Terminating rerackup..." | |
exit 0 | |
} | |
Restart () { | |
Stop | |
Start $@ | |
WatchForChanges $@ | |
} | |
WatchForChanges () { | |
echo "Watching for changes" | |
inotifywait -r -q -e modify . | |
Restart $@ | |
} | |
WatchForChanges $@ & Start $@ | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment