Show More
@@ -0,0 +1,60 | |||
|
1 | #!/sbin/runscript | |
|
2 | ######################################## | |
|
3 | #### THIS IS AN GENTOO INIT.D SCRIPT#### | |
|
4 | ######################################## | |
|
5 | ||
|
6 | APP_NAME="hg_app" | |
|
7 | APP_HOMEDIR="marcink/python_workspace" | |
|
8 | APP_PATH="/home/$APP_HOMEDIR/$APP_NAME" | |
|
9 | ||
|
10 | CONF_NAME="production.ini" | |
|
11 | ||
|
12 | PID_PATH="$APP_PATH/$APP_NAME.pid" | |
|
13 | LOG_PATH="$APP_PATH/$APP_NAME.log" | |
|
14 | ||
|
15 | PYTHON_PATH="/home/$APP_HOMEDIR/v-env" | |
|
16 | ||
|
17 | RUN_AS="marcink" | |
|
18 | ||
|
19 | DAEMON="$PYTHON_PATH/bin/paster" | |
|
20 | ||
|
21 | DAEMON_OPTS="serve --daemon \ | |
|
22 | --user=$RUN_AS \ | |
|
23 | --group=$RUN_AS \ | |
|
24 | --pid-file=$PID_PATH \ | |
|
25 | --log-file=$LOG_PATH $APP_PATH/$CONF_NAME" | |
|
26 | ||
|
27 | #extra options | |
|
28 | opts="${opts} restartdelay" | |
|
29 | ||
|
30 | depend() { | |
|
31 | need nginx | |
|
32 | } | |
|
33 | ||
|
34 | start() { | |
|
35 | ebegin "Starting $APP_NAME" | |
|
36 | cd $APP_PATH | |
|
37 | start-stop-daemon --start --quiet\ | |
|
38 | --pidfile $PID_PATH \ | |
|
39 | --user $RUN_AS \ | |
|
40 | --exec $DAEMON -- $DAEMON_OPTS | |
|
41 | eend $? | |
|
42 | } | |
|
43 | ||
|
44 | stop() { | |
|
45 | ebegin "Stopping $APP_NAME" | |
|
46 | start-stop-daemon --stop --quiet \ | |
|
47 | --pidfile $PID_PATH || echo "$APP_NAME - Not running!" | |
|
48 | if [ -f $PID_PATH ]; then | |
|
49 | rm $PID_PATH | |
|
50 | fi | |
|
51 | eend $? | |
|
52 | } | |
|
53 | ||
|
54 | restartdelay() { | |
|
55 | #stop() | |
|
56 | echo "sleep3" | |
|
57 | sleep 3 | |
|
58 | ||
|
59 | #start() | |
|
60 | } |
@@ -1,33 +1,70 | |||
|
1 | 1 | #!/bin/sh -e |
|
2 | ######################################## | |
|
3 | #### THIS IS AN DEBIAN INIT.D SCRIPT#### | |
|
4 | ######################################## | |
|
5 | ||
|
2 | 6 | ### BEGIN INIT INFO |
|
3 |
# Provides: |
|
|
7 | # Provides: hg-app | |
|
4 | 8 | # Required-Start: $all |
|
5 | 9 | # Required-Stop: $all |
|
6 | 10 | # Default-Start: 2 3 4 5 |
|
7 | 11 | # Default-Stop: 0 1 6 |
|
8 |
# Short-Description: starts |
|
|
9 |
# Description: starts |
|
|
12 | # Short-Description: starts instance of hg-app | |
|
13 | # Description: starts instance of hg-app using start-stop-daemon | |
|
10 | 14 | ### END INIT INFO |
|
11 | 15 | |
|
12 | project_name=hg_app | |
|
13 | conf_name=production.ini | |
|
14 | project_path=/home/marcink/python_workspace/$project_name | |
|
15 | pid_path=$project_path | |
|
16 | log_path=$project_path | |
|
17 | virt_python=/home/marcink/virt_python | |
|
18 | run_user=root | |
|
19 | run_group=root | |
|
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" | |
|
20 | 26 | |
|
21 | cd $project_path | |
|
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 | ||
|
22 | 38 | case "$1" in |
|
23 | 39 | start) |
|
24 | $virt_python/bin/paster serve --daemon --user=$run_user --group=$run_group --pid-file=$pid_path/$project_name.pid --log-file=$log_path/$project_name.log $project_path/$conf_name 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 | |
|
25 | 46 | ;; |
|
26 | 47 | stop) |
|
27 | $virt_python/bin/paster serve --daemon --user=$run_user --group=$run_group --pid-file=$pid_path/$project_name.pid --log-file=$log_path/$project_namete.log $project_path/$conf_name 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 | |
|
28 | 54 | ;; |
|
29 | 55 | restart) |
|
30 | $virt_python/bin/paster serve --daemon --user=$run_user --group=$run_group --pid-file=$pid_path/$project_name.pid --log-file=$log_path/$project_name.log $project_path/$conf_name 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 | |
|
31 | 68 | ;; |
|
32 | 69 | *) |
|
33 | 70 | echo "Usage: $0 {start|stop|restart}" |
General Comments 0
You need to be logged in to leave comments.
Login now