Created
February 9, 2012 15:18
-
-
Save pjammer/1780624 to your computer and use it in GitHub Desktop.
i put this into /usr/local/bin/eunic and you can your server using eunic -s && eunic -N
This file contains hidden or 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 | |
set -u | |
set -e | |
#change this below to your actual path. If you another environemnt like staging, fucking change N to -e staging instead. | |
APP_PATH=/youpath/to/app/root | |
PID=$APP_PATH/tmp/pids/unicorn.pid | |
OLD_PID=$APP_PATH/tmp/pids/unicorn.pid.oldbin | |
UNICORN_COMMAND="unicorn_rails -c $APP_PATH/config/unicorn.rb -D" | |
while getopts ":nsNr" opt; do | |
case $opt in | |
N) | |
echo "Starting Unicorn in Production" | |
unicorn_rails -E production -c $APP_PATH/config/unicorn.rb -D | |
;; | |
n) | |
echo "Starting Unicorn in Development" | |
$UNICORN_COMMAND | |
;; | |
s) | |
echo "Stopping Unicorn" | |
kill -15 `cat $PID` | |
;; | |
r) | |
echo "Reloading Unicorn if USR2 is enabled" | |
kill -USR2 `cat $PID` | |
if [ -s $OLD_PID ] | |
then | |
kill -WINCH `cat $OLD_PID` && kill -QUIT `cat $OLD_PID` | |
fi | |
;; | |
?) | |
echo "Usage: -n [start dev mode] | -N [ start Production mode] | -r [restart/reload] | -s [stop unicorn]" | |
exit 1 | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i hope those are comments in bash too, but make sure you chmod +x /usr/local/bin/eunic after you create this file on your server.