##// END OF EJS Templates
more on that neverending topic :) init scripts
marcink -
r433:aeafda54 default
parent child Browse files
Show More
@@ -1,76 +1,77 b''
1 1 #!/bin/sh -e
2 2 ########################################
3 3 #### THIS IS AN DEBIAN INIT.D SCRIPT####
4 4 ########################################
5 5
6 6 ### BEGIN INIT INFO
7 7 # Provides: hg-app
8 8 # Required-Start: $all
9 9 # Required-Stop: $all
10 10 # Default-Start: 2 3 4 5
11 11 # Default-Stop: 0 1 6
12 12 # Short-Description: starts instance of hg-app
13 13 # Description: starts instance of hg-app using start-stop-daemon
14 14 ### END INIT INFO
15 15
16 16 APP_NAME="hg_app"
17 17 APP_HOMEDIR="marcink/python_workspace"
18 18 APP_PATH="/home/$APP_HOMEDIR/$APP_NAME"
19 19
20 20 CONF_NAME="production.ini"
21 21
22 22 PID_PATH="$APP_PATH/$APP_NAME.pid"
23 23 LOG_PATH="$APP_PATH/$APP_NAME.log"
24 24
25 25 PYTHON_PATH="/home/$APP_HOMEDIR/v-env"
26 26
27 27 RUN_AS="marcink"
28 28
29 29 DAEMON="$PYTHON_PATH/bin/paster"
30 30
31 31 DAEMON_OPTS="serve --daemon \
32 32 --user=$RUN_AS \
33 33 --group=$RUN_AS \
34 34 --pid-file=$PID_PATH \
35 35 --log-file=$LOG_PATH $APP_PATH/$CONF_NAME"
36 36
37 37
38 38 case "$1" in
39 39 start)
40 40 echo "Starting $APP_NAME"
41 41 start-stop-daemon -d $APP_PATH -e PYTHON_EGG_CACHE="/tmp" \
42 42 --start --quiet \
43 43 --pidfile $PID_PATH \
44 44 --user $RUN_AS \
45 45 --exec $DAEMON -- $DAEMON_OPTS
46 46 ;;
47 47 stop)
48 48 echo "Stopping $APP_NAME"
49 49 start-stop-daemon -d $APP_PATH \
50 50 --stop --quiet \
51 51 --pidfile $PID_PATH || echo "$APP_NAME - Not running!"
52 52 if [ -f $PID_PATH ]; then
53 53 rm $PID_PATH
54 54 fi
55 55 ;;
56 56 restart)
57 57 echo "Restarting $APP_NAME"
58 58 ### stop ###
59 59 echo "Stopping $APP_NAME"
60 60 start-stop-daemon -d $APP_PATH \
61 61 --stop --quiet \
62 62 --pidfile $PID_PATH || echo "$APP_NAME - Not running!"
63 63 if [ -f $PID_PATH ]; then
64 64 rm $PID_PATH
65 65 fi
66 66 ### start ###
67 67 echo "Starting $APP_NAME"
68 68 start-stop-daemon -d $APP_PATH -e PYTHON_EGG_CACHE="/tmp" \
69 69 --start --quiet \
70 70 --pidfile $PID_PATH \
71 71 --user $RUN_AS \
72 72 --exec $DAEMON -- $DAEMON_OPTS
73 ;;
73 74 *)
74 75 echo "Usage: $0 {start|stop|restart}"
75 76 exit 1
76 77 esac No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now