rhodecode-daemon2
89 lines
| 1.7 KiB
| text/plain
|
TextLexer
/ init.d / rhodecode-daemon2
r552 | #!/bin/sh -e | ||
######################################## | |||
r1262 | #### THIS IS A DEBIAN INIT.D SCRIPT #### | ||
r552 | ######################################## | ||
r3225 | |||
r552 | ### BEGIN INIT INFO | ||
# Provides: rhodecode | |||
# Required-Start: $all | |||
# Required-Stop: $all | |||
# Default-Start: 2 3 4 5 | |||
# Default-Stop: 0 1 6 | |||
# Short-Description: starts instance of rhodecode | |||
# Description: starts instance of rhodecode using start-stop-daemon | |||
### END INIT INFO | |||
r3225 | |||
r552 | APP_NAME="rhodecode" | ||
r3225 | APP_HOMEDIR="opt" | ||
APP_PATH="/$APP_HOMEDIR/$APP_NAME" | |||
r552 | CONF_NAME="production.ini" | ||
r3225 | |||
r552 | PID_PATH="$APP_PATH/$APP_NAME.pid" | ||
LOG_PATH="$APP_PATH/$APP_NAME.log" | |||
r3225 | |||
PYTHON_PATH="/$APP_HOMEDIR/$APP_NAME-venv" | |||
RUN_AS="root" | |||
r552 | DAEMON="$PYTHON_PATH/bin/paster" | ||
r3225 | |||
r552 | DAEMON_OPTS="serve --daemon \ | ||
r3225 | --user=$RUN_AS \ | ||
--group=$RUN_AS \ | |||
--pid-file=$PID_PATH \ | |||
--log-file=$LOG_PATH $APP_PATH/$CONF_NAME" | |||
r1262 | start() { | ||
echo "Starting $APP_NAME" | |||
PYTHON_EGG_CACHE="/tmp" start-stop-daemon -d $APP_PATH \ | |||
--start --quiet \ | |||
--pidfile $PID_PATH \ | |||
--user $RUN_AS \ | |||
--exec $DAEMON -- $DAEMON_OPTS | |||
} | |||
r3225 | |||
r1262 | stop() { | ||
echo "Stopping $APP_NAME" | |||
start-stop-daemon -d $APP_PATH \ | |||
--stop --quiet \ | |||
--pidfile $PID_PATH || echo "$APP_NAME - Not running!" | |||
r3225 | |||
r1262 | if [ -f $PID_PATH ]; then | ||
rm $PID_PATH | |||
fi | |||
} | |||
r3225 | |||
status() { | |||
echo -n "Checking status of $APP_NAME ... " | |||
pid=`cat $PID_PATH` | |||
status=`ps ax | grep $pid | grep -ve grep` | |||
if [ "$?" -eq 0 ]; then | |||
echo "running" | |||
else | |||
echo "NOT running" | |||
fi | |||
} | |||
r552 | case "$1" in | ||
r3225 | status) | ||
status | |||
;; | |||
r552 | start) | ||
r1262 | start | ||
r552 | ;; | ||
stop) | |||
r1262 | stop | ||
r552 | ;; | ||
restart) | |||
echo "Restarting $APP_NAME" | |||
### stop ### | |||
r1262 | stop | ||
wait | |||
r552 | ### start ### | ||
r1262 | start | ||
r552 | ;; | ||
*) | |||
echo "Usage: $0 {start|stop|restart}" | |||
exit 1 | |||
r3225 | esac |