Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (33 sloc) 860 Bytes
#!/bin/bash
PIDFILE="/var/run/githook.pid"
EXEC="/usr/bin/ruby"
TOKEN_PATH="/etc/environment.githook"
DEPLOY_PATH="/home/yuliang/githook"
SCRIPT="$DEPLOY_PATH/server.rb"
LOG="$DEPLOY_PATH/server.log"
function start_service {
echo Starting Service...
cd $DEPLOY_PATH
source $TOKEN_PATH
start-stop-daemon --start --make-pidfile --pidfile $PIDFILE --chdir . --startas $EXEC -- $SCRIPT >> $LOG 2>&1 &
}
function stop_service {
echo Stop Service...
cd $DEPLOY_PATH; start-stop-daemon --stop --pidfile $PIDFILE --retry TERM/30/KILL/5
}
function usage {
echo "Usage:"
echo -e "\t`basename $0` {start|stop|restart}"
}
if [ -z "$1" ]; then
usage
elif [ "$1" == "start" ]; then
start_service
elif [ "$1" == "stop" ]; then
stop_service
elif [ "$1" == "restart" ]; then
stop_service
start_service
else
usage
fi