Forked from waiting-for-dev/rails_server_helper.bash
Last active
January 11, 2018 14:01
-
-
Save kobeumut/7ba146848a3974e9527669c21adf3b3d to your computer and use it in GitHub Desktop.
Stop and restart easily a rails server.
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
function rails() { | |
if [ "$1" = "start" ]; then | |
if [ "$2" = "" ]; then | |
RENV="production" | |
else | |
RENV="$2" | |
fi | |
rails server -p 80 -b 0.0.0.0 -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