Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
i put this into /usr/local/bin/eunic and you can your server using eunic -s && eunic -N
#!/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
@pjammer

This comment has been minimized.

Copy link
Owner Author

@pjammer pjammer commented Feb 9, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment