Created
December 4, 2015 11:09
-
-
Save mattrayner/4bc27c81fa48f3d767f1 to your computer and use it in GitHub Desktop.
Open a local rails development server, binding it to your LAN IP and a port of your choice (or 3000) to allow easy sharing within teams or for mobile deice testing
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
#!/bin/bash | |
echo ========================== | |
echo Local Rails Launcher | |
echo ---- | |
echo | |
echo Getting local IP Address | |
echo -------------------------- | |
echo | |
# Get the local IP address | |
LOCAL_IP=$(ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}') | |
echo $LOCAL_IP | |
echo | |
echo -------------------------- | |
echo Launching Rails | |
echo ---- | |
echo | |
# Set the default rails port | |
RAILS_PORT=3000 | |
if [ "$1" = "port" ];then | |
RAILS_PORT=$2 | |
echo | |
echo Using custom port | |
echo -------------------------- | |
echo | |
echo $RAILS_PORT | |
echo | |
echo -------------------------- | |
fi | |
echo Rails will be at | |
echo -------------------------- | |
echo | |
echo http://$LOCAL_IP:$RAILS_PORT | |
echo | |
read -p "Press [Enter] to launch rails..." | |
bundle exec rails s -b $LOCAL_IP -p $RAILS_PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment