Last active
December 11, 2015 21:28
-
-
Save moqada/4662437 to your computer and use it in GitHub Desktop.
init script for fulcrum
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/sh | |
| # | |
| # chkconfig: 2345 80 30 | |
| # processname: fulcrum | |
| # description: Fulcrum Unicorn process | |
| PORT=5000 | |
| APP_ROOT=/home/fulcrum/fulcrum | |
| UNICORN_PID=$APP_ROOT/tmp/unicorn.pid | |
| check_pid() { | |
| if [ -f $UNICORN_PID ]; then | |
| PID=`cat $UNICORN_PID` | |
| STATUS=`ps aux | grep $PID | grep -v grep | wc -l` | |
| else | |
| STATUS=0 | |
| PID=0 | |
| fi | |
| } | |
| start() { | |
| cd $APP_ROOT | |
| check_pid | |
| if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
| echo "Error! is currentry running!" | |
| exit 1 | |
| else | |
| if [ `whoami` = root ]; then | |
| sudo -u fulcrum -H bash -l -c "unicorn_rails -c config/unicorn.rb -E production -p $PORT -D" | |
| echo "Fulcrum started" | |
| fi | |
| fi | |
| } | |
| stop() { | |
| cd $APP_ROOT | |
| check_pid | |
| if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
| kill -QUIT `cat $UNICORN_PID` | |
| rm $UNICORN_PID | |
| echo "Fulcrum stopped" | |
| else | |
| echo "Error! not started!" | |
| exit 1 | |
| fi | |
| } | |
| restart() { | |
| cd $APP_ROOT | |
| check_pid | |
| if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
| echo "Restarting Fulcrum" | |
| kill -QUIT `cat $UNICORN_PID` | |
| rm $UNICORN_PID | |
| start | |
| else | |
| echo "Error not running" | |
| exit 1 | |
| fi | |
| } | |
| status() { | |
| cd $APP_ROOT | |
| check_pid | |
| if [ "$PID" -ne 0 -a "$STATUS" -ne 0 ]; then | |
| echo "Unicorn with PID $PID is running" | |
| else | |
| echo "is not running" | |
| exit 1 | |
| fi | |
| } | |
| case "$1" in | |
| start) | |
| start | |
| ;; | |
| stop) | |
| stop | |
| ;; | |
| restart) | |
| restart | |
| ;; | |
| status) | |
| status | |
| ;; | |
| *) | |
| echo "Usage: sudo service fulcrum {start|stop|restart|reload}" >&2 | |
| exit 1 | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
Can you give me a hit how to install unicorn so that it works fulcrum ?