Skip to content

Instantly share code, notes, and snippets.

@kobeumut
Forked from waiting-for-dev/rails_server_helper.bash
Last active January 11, 2018 14:01
Show Gist options
  • Save kobeumut/7ba146848a3974e9527669c21adf3b3d to your computer and use it in GitHub Desktop.
Save kobeumut/7ba146848a3974e9527669c21adf3b3d to your computer and use it in GitHub Desktop.
Stop and restart easily a rails server.
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