comparison init.d/rhodecode-daemon3 @ 1542:238b2805851f beta

added a RedHat-based init.d startup script
author Les Peabody <lpeabody@gmail.com>
date Tue, 11 Oct 2011 02:13:32 -0400
parents
children a7bee2a5de67
comparison
equal deleted inserted replaced
1541:70e646b2806a 1542:238b2805851f
1 #!/bin/sh
2 ##################################################
3 #
4 # RhodeCode server startup script
5 # Recommended default-startup: 2 3 4 5
6 # Recommended default-stop: 0 1 6
7 #
8 ##################################################
9
10
11 APP_NAME="rhodecode"
12 # the location of your app
13 # since this is a web app, it should go in /var/www
14 APP_PATH="/var/www/$APP_NAME"
15
16 CONF_NAME="production.ini"
17
18 # write to wherever the PID should be stored, just ensure
19 # that the user you run paster as has the appropriate permissions
20 # same goes for the log file
21 PID_PATH="/var/run/rhodecode/pid"
22 LOG_PATH="/var/log/rhodecode/rhodecode.log"
23
24 # replace this with the path to the virtual environment you
25 # made for RhodeCode
26 PYTHON_PATH="/opt/python_virtualenvironments/rhodecode-venv"
27
28 RUN_AS="rhodecode"
29
30 DAEMON="$PYTHON_PATH/bin/paster"
31
32 DAEMON_OPTS="serve --daemon \
33 --user=$RUN_AS \
34 --group=$RUN_AS \
35 --pid-file=$PID_PATH \
36 --log-file=$LOG_PATH $APP_PATH/$CONF_NAME"
37
38 DESC="rhodecode-server"
39 LOCK_FILE="/var/lock/subsys/$APP_NAME"
40
41 # source CentOS init functions
42 . /etc/init.d/functions
43
44 RETVAL=0
45
46 remove_pid () {
47 rm -f ${PID_PATH}
48 rmdir `dirname ${PID_PATH}`
49 }
50
51 ensure_pid_dir () {
52 PID_DIR=`dirname ${PID_PATH}`
53 if [ ! -d ${PID_DIR} ] ; then
54 mkdir -p ${PID_DIR}
55 chown -R ${RUN_AS}:${RUN_AS} ${PID_DIR}
56 chmod 755 ${PID_DIR}
57 fi
58 }
59
60 start_rhodecode () {
61 ensure_pid_dir
62 PYTHON_EGG_CACHE="/tmp" daemon --pidfile $PID_PATH \
63 --user $RUN_AS "$DAEMON $DAEMON_OPTS"
64 RETVAL=$?
65 [ $RETVAL -eq 0 ] && touch $LOCK_FILE
66 return $RETVAL
67 }
68
69 stop_rhodecode () {
70 if [ -e $LOCK_FILE ]; then
71 killproc -p $PID_PATH
72 RETVAL=$?
73 rm -f $LOCK_FILE
74 rm -f $PID_PATH
75 else
76 RETVAL=1
77 fi
78 return $RETVAL
79 }
80
81 status_rhodecode() {
82 if [ -e $LOCK_FILE ]; then
83 # exit with non-zero to indicate failure
84 RETVAL=1
85 else
86 RETVAL=0
87 fi
88 return $RETVAL
89 }
90
91 restart_rhodecode () {
92 stop_rhodecode
93 start_rhodecode
94 RETVAL=$?
95 }
96
97 case "$1" in
98 start)
99 echo -n $"Starting $DESC: "
100 start_rhodecode
101 echo
102 ;;
103 stop)
104 echo -n $"Stopping $DESC: "
105 stop_rhodecode
106 echo
107 ;;
108 status)
109 status_rhodecode
110 RETVAL=$?
111 if [ ! $RETVAL -eq 0 ]; then
112 echo "RhodeCode server is running..."
113 else
114 echo "RhodeCode server is stopped."
115 fi
116 ;;
117 restart)
118 echo -n $"Restarting $DESC: "
119 restart_rhodecode
120 echo
121 ;;
122 *)
123 echo $"Usage: $0 {start|stop|restart|status}"
124 RETVAL=1
125 ;;
126 esac
127
128 exit $RETVAL