Skip to content

Instantly share code, notes, and snippets.

@ramonrails ramonrails/
Last active Jul 9, 2018

What would you like to do?
puma-dev management script
# author:
# 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
${cyan}${bold}pumad add|remove|kill${reset} (while in the rails app folder)
pumad add # adds ~/.puma-dev/<current-folder>
pumad remove # removes ~/.puma-dev/<current-folder>
pumad kill # kills puma-dev process
# 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`)"
if [ ! -f Gemfile ]; then
echo "Run this command from rails app folder"
exit 0
# no parameters given?, show formatted help
if [[ $# -eq 0 ]]; then
exit 0
# /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!"
echo "Your app configuration failed! Please try again or check the error on console."
# 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
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.