Last active
September 10, 2020 18:14
-
-
Save ramonrails/d7056dd8af8c583f56493903fefbdb0c to your computer and use it in GitHub Desktop.
puma-dev management script
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 | |
# 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