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