Skip to content

Instantly share code, notes, and snippets.

@ramonrails ramonrails/puma-dev.sh
Last active Jul 9, 2018

Embed
What would you like to do?
puma-dev management script
#!/bin/bash
# author: ramonrails.in
# version: 1.0
# release date: 7-Aug-2017
# license: MIT
# style for output
bold=$(tput bold)
cyan=$(tput setaf 6)
yellow=$(tput setaf 3)
reset=$(tput sgr0)
# help display in console, as a function
show_help() {
echo "
${cyan}puma-dev${reset} management
usage:
${cyan}${bold}pumad add|remove|kill${reset} (while in the rails app folder)
${bold}example${reset}:
pumad add # adds ~/.puma-dev/<current-folder>
pumad remove # removes ~/.puma-dev/<current-folder>
pumad kill # kills puma-dev process
${yellow}hint:
# first time setup:
# 1. install puma-dev (on a Mac you can 'brew install puma/puma/puma-dev')
# 2. sudo puma-dev -setup
# 3. puma-dev -install
${cyan}${bold}ln -s "$(pwd)" ~/.puma-dev/"$(basename `pwd`)"
${reset}
"
}
if [ ! -f Gemfile ]; then
echo "Run this command from rails app folder"
exit 0
fi
# no parameters given?, show formatted help
if [[ $# -eq 0 ]]; then
show_help
exit 0
fi
# /usr/local/bin/pumad +x
#
# add this rails app to puma dev
if [ $1 == 'add' ]; then
ln -s "$(pwd)" ~/.puma-dev/"$(basename `pwd`)"
puma-dev -install
if [ -d ~/.puma-dev/$(basename `pwd`) ]; then
echo "Your app should be available at http://$(basename `pwd`).dev and https://$(basename `pwd`).dev now!"
else
echo "Your app configuration failed! Please try again or check the error on console."
fi
# remove this rails app from puma-dev
elif [ $1 == 'remove' ]; then
rm ~/.puma-dev/"$(basename `pwd`)"
# kill puma-dev for a restart
elif [ $1 == 'kill' ]; then
pkill -USR1 puma-dev
# show help
else
show_help
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.