##// END OF EJS Templates
Added suggested init.d modifications
marcink -
r1:8b39dc58 tip default draft
parent child Browse files
Show More
@@ -1,140 +1,143 b''
1 #!/bin/sh
1 #!/bin/sh
2 ########################################
2 ########################################
3 #### THIS IS A REDHAT INIT.D SCRIPT ####
3 #### THIS IS A REDHAT INIT.D SCRIPT ####
4 ########################################
4 ########################################
5 #
6 # description: RhodeCode Server Startup Script
7 # chkconfig: 2345 90 10
5
8
6 ##################################################
9 ##################################################
7 #
10 #
8 # RhodeCode server startup script
11 # RhodeCode server startup script
9 # Recommended default-startup: 2 3 4 5
12 # Recommended default-startup: 2 3 4 5
10 # Recommended default-stop: 0 1 6
13 # Recommended default-stop: 0 1 6
11 #
14 #
12 ##################################################
15 ##################################################
13
16
14 ## fix for locale not loading when starting service
17 ## fix for locale not loading when starting service
15 ## uncomment if you have issues with accent characters after RhodeCode starts
18 ## uncomment if you have issues with accent characters after RhodeCode starts
16 ## on boot
19 ## on boot
17 #if [ -r /etc/default/locale ]; then
20 #if [ -r /etc/default/locale ]; then
18 # . /etc/default/locale
21 # . /etc/default/locale
19 # export LANG
22 # export LANG
20 #fi
23 #fi
21
24
22 APP_NAME="rhodecode"
25 APP_NAME="rhodecode"
23 # the location of your app
26 # the location of your app
24 # since this is a web app, it should go in /var/www
27 # since this is a web app, it should go in /var/www
25 APP_PATH="/var/www/$APP_NAME"
28 APP_PATH="/var/www/$APP_NAME"
26
29
27 CONF_NAME="production.ini"
30 CONF_NAME="production.ini"
28
31
29 # write to wherever the PID should be stored, just ensure
32 # write to wherever the PID should be stored, just ensure
30 # that the user you run paster as has the appropriate permissions
33 # that the user you run paster as has the appropriate permissions
31 # same goes for the log file
34 # same goes for the log file
32 PID_PATH="/var/run/rhodecode/pid"
35 PID_PATH="/var/run/rhodecode/pid"
33 LOG_PATH="/var/log/rhodecode/rhodecode.log"
36 LOG_PATH="/var/log/rhodecode/rhodecode.log"
34
37
35 # replace this with the path to the virtual environment you
38 # replace this with the path to the virtual environment you
36 # made for RhodeCode
39 # made for RhodeCode
37 PYTHON_PATH="/opt/python_virtualenvironments/rhodecode-venv"
40 PYTHON_PATH="/opt/python_virtualenvironments/rhodecode-venv"
38
41
39 RUN_AS_USER="rhodecode"
42 RUN_AS_USER="rhodecode"
40 RUN_AS_GROUP="rhodecode"
43 RUN_AS_GROUP="rhodecode"
41
44
42 DAEMON="$PYTHON_PATH/bin/paster"
45 DAEMON="$PYTHON_PATH/bin/paster"
43
46
44 DAEMON_OPTS="serve --daemon \
47 DAEMON_OPTS="serve --daemon \
45 --user=$RUN_AS_USER \
48 --user=$RUN_AS_USER \
46 --group=$RUN_AS_GROUP \
49 --group=$RUN_AS_GROUP \
47 --pid-file=$PID_PATH \
50 --pid-file=$PID_PATH \
48 --log-file=$LOG_PATH $APP_PATH/$CONF_NAME"
51 --log-file=$LOG_PATH $APP_PATH/$CONF_NAME"
49
52
50 DESC="rhodecode-server"
53 DESC="rhodecode-server"
51 LOCK_FILE="/var/lock/subsys/$APP_NAME"
54 LOCK_FILE="/var/lock/subsys/$APP_NAME"
52
55
53 # source CentOS init functions
56 # source CentOS init functions
54 . /etc/init.d/functions
57 . /etc/init.d/functions
55
58
56 RETVAL=0
59 RETVAL=0
57
60
58 remove_pid () {
61 remove_pid () {
59 rm -f ${PID_PATH}
62 rm -f ${PID_PATH}
60 rmdir `dirname ${PID_PATH}`
63 rmdir `dirname ${PID_PATH}`
61 }
64 }
62
65
63 ensure_pid_dir () {
66 ensure_pid_dir () {
64 PID_DIR=`dirname ${PID_PATH}`
67 PID_DIR=`dirname ${PID_PATH}`
65 if [ ! -d ${PID_DIR} ] ; then
68 if [ ! -d ${PID_DIR} ] ; then
66 mkdir -p ${PID_DIR}
69 mkdir -p ${PID_DIR}
67 chown -R ${RUN_AS}:${RUN_AS} ${PID_DIR}
70 chown -R ${RUN_AS}:${RUN_AS} ${PID_DIR}
68 chmod 755 ${PID_DIR}
71 chmod 755 ${PID_DIR}
69 fi
72 fi
70 }
73 }
71
74
72 start_rhodecode () {
75 start_rhodecode () {
73 ensure_pid_dir
76 ensure_pid_dir
74 PYTHON_EGG_CACHE="/tmp" daemon --pidfile $PID_PATH \
77 PYTHON_EGG_CACHE="/tmp" daemon --pidfile $PID_PATH \
75 --user $RUN_AS "$DAEMON $DAEMON_OPTS"
78 --user $RUN_AS "$DAEMON $DAEMON_OPTS"
76 RETVAL=$?
79 RETVAL=$?
77 [ $RETVAL -eq 0 ] && touch $LOCK_FILE
80 [ $RETVAL -eq 0 ] && touch $LOCK_FILE
78 return $RETVAL
81 return $RETVAL
79 }
82 }
80
83
81 stop_rhodecode () {
84 stop_rhodecode () {
82 if [ -e $LOCK_FILE ]; then
85 if [ -e $LOCK_FILE ]; then
83 killproc -p $PID_PATH
86 killproc -p $PID_PATH
84 RETVAL=$?
87 RETVAL=$?
85 rm -f $LOCK_FILE
88 rm -f $LOCK_FILE
86 rm -f $PID_PATH
89 rm -f $PID_PATH
87 else
90 else
88 RETVAL=1
91 RETVAL=1
89 fi
92 fi
90 return $RETVAL
93 return $RETVAL
91 }
94 }
92
95
93 status_rhodecode() {
96 status_rhodecode() {
94 if [ -e $LOCK_FILE ]; then
97 if [ -e $LOCK_FILE ]; then
95 # exit with non-zero to indicate failure
98 # exit with non-zero to indicate failure
96 RETVAL=1
99 RETVAL=1
97 else
100 else
98 RETVAL=0
101 RETVAL=0
99 fi
102 fi
100 return $RETVAL
103 return $RETVAL
101 }
104 }
102
105
103 restart_rhodecode () {
106 restart_rhodecode () {
104 stop_rhodecode
107 stop_rhodecode
105 start_rhodecode
108 start_rhodecode
106 RETVAL=$?
109 RETVAL=$?
107 }
110 }
108
111
109 case "$1" in
112 case "$1" in
110 start)
113 start)
111 echo -n $"Starting $DESC: "
114 echo -n $"Starting $DESC: "
112 start_rhodecode
115 start_rhodecode
113 echo
116 echo
114 ;;
117 ;;
115 stop)
118 stop)
116 echo -n $"Stopping $DESC: "
119 echo -n $"Stopping $DESC: "
117 stop_rhodecode
120 stop_rhodecode
118 echo
121 echo
119 ;;
122 ;;
120 status)
123 status)
121 status_rhodecode
124 status_rhodecode
122 RETVAL=$?
125 RETVAL=$?
123 if [ ! $RETVAL -eq 0 ]; then
126 if [ ! $RETVAL -eq 0 ]; then
124 echo "RhodeCode server is running..."
127 echo "RhodeCode server is running..."
125 else
128 else
126 echo "RhodeCode server is stopped."
129 echo "RhodeCode server is stopped."
127 fi
130 fi
128 ;;
131 ;;
129 restart)
132 restart)
130 echo -n $"Restarting $DESC: "
133 echo -n $"Restarting $DESC: "
131 restart_rhodecode
134 restart_rhodecode
132 echo
135 echo
133 ;;
136 ;;
134 *)
137 *)
135 echo $"Usage: $0 {start|stop|restart|status}"
138 echo $"Usage: $0 {start|stop|restart|status}"
136 RETVAL=1
139 RETVAL=1
137 ;;
140 ;;
138 esac
141 esac
139
142
140 exit $RETVAL
143 exit $RETVAL
General Comments 0
You need to be logged in to leave comments. Login now