comparison init.d/rhodecode-daemon4 @ 2114:0dc18e9a3150 beta

added arch example init.d
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 08 Mar 2012 05:30:41 +0200
parents
children
comparison
equal deleted inserted replaced
2113:5a1a07567b18 2114:0dc18e9a3150
1 #!/bin/bash
2 ###########################################
3 #### THIS IS AN ARCH LINUX RC.D SCRIPT ####
4 ###########################################
5
6 . /etc/rc.conf
7 . /etc/rc.d/functions
8
9 DAEMON=rhodecode
10 APP_HOMEDIR="/srv"
11 APP_PATH="$APP_HOMEDIR/$DAEMON"
12 CONF_NAME="production.ini"
13 LOG_FILE="/var/log/$DAEMON.log"
14 PID_FILE="/run/daemons/$DAEMON"
15 APPL=/usr/bin/paster
16 RUN_AS="*****"
17
18 ARGS="serve --daemon \
19 --user=$RUN_AS \
20 --group=$RUN_AS \
21 --pid-file=$PID_FILE \
22 --log-file=$LOG_FILE \
23 $APP_PATH/$CONF_NAME"
24
25 [ -r /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON
26
27 if [[ -r $PID_FILE ]]; then
28 read -r PID < "$PID_FILE"
29 if [[ $PID && ! -d /proc/$PID ]]; then
30 unset PID
31 rm_daemon $DAEMON
32 fi
33 fi
34
35 case "$1" in
36 start)
37 stat_busy "Starting $DAEMON"
38 export HOME=$APP_PATH
39 [ -z "$PID" ] && $APPL $ARGS &>/dev/null
40 if [ $? = 0 ]; then
41 add_daemon $DAEMON
42 stat_done
43 else
44 stat_fail
45 exit 1
46 fi
47 ;;
48 stop)
49 stat_busy "Stopping $DAEMON"
50 [ -n "$PID" ] && kill $PID &>/dev/null
51 if [ $? = 0 ]; then
52 rm_daemon $DAEMON
53 stat_done
54 else
55 stat_fail
56 exit 1
57 fi
58 ;;
59 restart)
60 $0 stop
61 sleep 1
62 $0 start
63 ;;
64 status)
65 stat_busy "Checking $name status";
66 ck_status $name
67 ;;
68 *)
69 echo "usage: $0 {start|stop|restart|status}"
70 esac