|
Revision 40, 1.8 KB
(checked in by jiangx, 4 years ago)
|
|
add init.d script
|
-
Property svn:eol-style set to
native
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #! /bin/sh |
|---|
| 2 | |
|---|
| 3 | ### BEGIN INIT INFO |
|---|
| 4 | # Provides: <my_app> application instance |
|---|
| 5 | # Required-Start: $all |
|---|
| 6 | # Required-Stop: $all |
|---|
| 7 | # Default-Start: 2 3 4 5 |
|---|
| 8 | # Default-Stop: 0 1 6 |
|---|
| 9 | # Short-Description: starts instance of <my_app> app |
|---|
| 10 | # Description: starts instance of <my app> app using start-stop-daemon |
|---|
| 11 | ### END INIT INFO |
|---|
| 12 | |
|---|
| 13 | ############### EDIT ME ################## |
|---|
| 14 | # path to workingenv install if any |
|---|
| 15 | #PYTHONPATH=<path to pylons workingenv>/lib/python2.4 |
|---|
| 16 | |
|---|
| 17 | # path to app |
|---|
| 18 | APP_PATH=/opt/svnadmin |
|---|
| 19 | |
|---|
| 20 | # path to paster bin |
|---|
| 21 | DAEMON=/usr/bin/paster |
|---|
| 22 | |
|---|
| 23 | # log file name |
|---|
| 24 | LOG_FILE=$APP_PATH/run/paster.log |
|---|
| 25 | |
|---|
| 26 | PID_FILE=$APP_PATH/run/paster.pid |
|---|
| 27 | |
|---|
| 28 | # startup args |
|---|
| 29 | DAEMON_OPTS=" serve --monitor-restart --log-file $LOG_FILE production.ini" |
|---|
| 30 | |
|---|
| 31 | # script name |
|---|
| 32 | NAME=svnadmin |
|---|
| 33 | |
|---|
| 34 | # app name |
|---|
| 35 | DESC=pySvnManager |
|---|
| 36 | |
|---|
| 37 | # pylons user |
|---|
| 38 | RUN_AS=www-data |
|---|
| 39 | |
|---|
| 40 | ############### END EDIT ME ################## |
|---|
| 41 | |
|---|
| 42 | test -x $DAEMON || exit 0 |
|---|
| 43 | |
|---|
| 44 | set -e |
|---|
| 45 | |
|---|
| 46 | case "$1" in |
|---|
| 47 | start) |
|---|
| 48 | if [ -f "$PID_FILE" ]; then |
|---|
| 49 | if [ -f "/proc/`cat $PID_FILE`/stat" ]; then |
|---|
| 50 | echo "Daemon aleady started? pid: `cat $PID_FILE`" |
|---|
| 51 | exit 1 |
|---|
| 52 | fi |
|---|
| 53 | fi |
|---|
| 54 | echo -n "Starting $DESC: " |
|---|
| 55 | start-stop-daemon -c $RUN_AS -d $APP_PATH --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS |
|---|
| 56 | echo "$NAME." |
|---|
| 57 | ;; |
|---|
| 58 | stop) |
|---|
| 59 | echo -n "Stopping $DESC: " |
|---|
| 60 | start-stop-daemon --stop --pidfile $PID_FILE |
|---|
| 61 | echo "$NAME." |
|---|
| 62 | ;; |
|---|
| 63 | |
|---|
| 64 | restart|force-reload) |
|---|
| 65 | echo -n "Restarting $DESC: " |
|---|
| 66 | start-stop-daemon --stop --pidfile $PID_FILE |
|---|
| 67 | sleep 1 |
|---|
| 68 | start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS |
|---|
| 69 | echo "$NAME." |
|---|
| 70 | ;; |
|---|
| 71 | *) |
|---|
| 72 | N=/etc/init.d/$NAME |
|---|
| 73 | echo "Usage: $N {start|stop|restart|force-reload}" >&2 |
|---|
| 74 | exit 1 |
|---|
| 75 | ;; |
|---|
| 76 | esac |
|---|
| 77 | |
|---|
| 78 | exit 0 |
|---|
| 79 | |
|---|