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