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