Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # chkconfig: 345 10 10
- # Description: Control Unicorn
- # Set app name
- NAME=""
- # Tweak yourself
- export HOME="/root"
- BUNDLE_PATH="/usr/local/bin/bundle"
- APP_DIR="/path/to/${NAME}"
- PID="/tmp/${NAME}.pid"
- CONFIG="${APP_DIR}/config/unicorn.rb"
- ENV="production"
- CMD="${BUNDLE_PATH} exec unicorn -c ${CONFIG} -E ${ENV} -D"
- start()
- {
- if [ -e $PID ]; then
- echo "${NAME} has already started."
- exit 1
- fi
- echo "Start ${NAME}..."
- cd $APP_DIR
- $CMD
- }
- stop()
- {
- if [ ! -e $PID ]; then
- echo "${NAME} is not started."
- exit 1
- fi
- echo "Stop ${NAME}..."
- kill -QUIT `cat ${PID}`
- }
- force_stop()
- {
- if [ ! -e $PID ]; then
- echo "${NAME} is not started."
- exit 1
- fi
- echo "Force stop ${NAME}..."
- kill -INT `cat ${PID}`
- }
- reload()
- {
- if [ ! -e $PID ]; then
- echo "${NAME} is not started."
- start
- exit 0
- fi
- echo "Reload ${NAME}..."
- kill -HUP `cat ${PID}`
- }
- restart()
- {
- if [ ! -e $PID ]; then
- echo "${NAME} is not started."
- start
- exit 0
- fi
- echo "Restart ${NAME}..."
- kill -USR2 `cat ${PID}`
- }
- case $1 in
- start)
- start
- ;;
- stop)
- stop
- ;;
- force-stop)
- force_stop
- ;;
- reload)
- reload
- ;;
- restart)
- restart
- ;;
- *)
- echo "Usage: [start|stop|force-stop|reload|restart]"
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement