Last active
January 11, 2018 13:53
-
-
Save waiting-for-dev/11495350 to your computer and use it in GitHub Desktop.
Stop and restart easily a rails server. http://waiting-for-dev.github.io/blog/2014/05/03/stop-and-restart-easily-a-rails-server/
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
function rails() { | |
if [ "$1" = "start" ]; then | |
if [ "$2" = "" ]; then | |
RENV="development" | |
else | |
RENV="$2" | |
fi | |
rails server -d -e "$RENV" | |
return 0 | |
elif [ "$1" = "stop" ]; then | |
if [ -f tmp/pids/server.pid ]; then | |
kill $2 $(cat tmp/pids/server.pid) | |
return 0 | |
else | |
echo "It seems there is no server running or you are not in a rails project root directory" | |
return 1 | |
fi | |
elif [ "$1" = "restart" ]; then | |
rails stop && rails start $2 | |
else | |
command rails $@ | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment