comparison hg_app_daemon2 @ 426:17d5028e055c

updated init scripts to start-stop-daemons
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 26 Aug 2010 17:28:11 +0200
parents manage-hg_app@7f88d7088f9c
children 41504f4aa96b
comparison
equal deleted inserted replaced
424:55ada111bca6 426:17d5028e055c
1 #!/bin/sh -e
2 ########################################
3 #### THIS IS AN DEBIAN INIT.D SCRIPT####
4 ########################################
5
6 ### BEGIN INIT INFO
7 # Provides: hg-app
8 # Required-Start: $all
9 # Required-Stop: $all
10 # Default-Start: 2 3 4 5
11 # Default-Stop: 0 1 6
12 # Short-Description: starts instance of hg-app
13 # Description: starts instance of hg-app using start-stop-daemon
14 ### END INIT INFO
15
16 APP_NAME="hg_app"
17 APP_HOMEDIR="marcink/python_workspace"
18 APP_PATH="/home/$APP_HOMEDIR/$APP_NAME"
19
20 CONF_NAME="production.ini"
21
22 PID_PATH="$APP_PATH/$APP_NAME.pid"
23 LOG_PATH="$APP_PATH/$APP_NAME.log"
24
25 PYTHON_PATH="/home/$APP_HOMEDIR/v-env"
26
27 RUN_AS="marcink"
28
29 DAEMON="$PYTHON_PATH/bin/paster"
30
31 DAEMON_OPTS="serve --daemon \
32 --user=$RUN_AS \
33 --group=$RUN_AS \
34 --pid-file=$PID_PATH \
35 --log-file=$LOG_PATH $APP_PATH/$CONF_NAME"
36
37
38 case "$1" in
39 start)
40 echo "Starting $APP_NAME"
41 cd $APP_PATH
42 start-stop-daemon --start --quiet\
43 --pidfile $PID_PATH \
44 --user $RUN_AS \
45 --exec $DAEMON -- $DAEMON_OPTS
46 ;;
47 stop)
48 echo "Stopping $APP_NAME"
49 start-stop-daemon --stop --quiet \
50 --pidfile $PID_PATH || echo "$APP_NAME - Not running!"
51 if [ -f $PID_PATH ]; then
52 rm $PID_PATH
53 fi
54 ;;
55 restart)
56 echo "Restarting $APP_NAME"
57 #stop
58 start-stop-daemon --stop --quiet \
59 --pidfile $PID_PATH || echo "$APP_NAME - Not running!"
60 if [ -f $PID_PATH ]; then
61 rm $PID_PATH
62 fi
63 #start
64 start-stop-daemon --start --quiet\
65 --pidfile $PID_PATH \
66 --user $RUN_AS \
67 --exec $DAEMON -- $DAEMON_OPTS
68 ;;
69 *)
70 echo "Usage: $0 {start|stop|restart}"
71 exit 1
72 esac