[Erp5-report] r14647 - /erp5/trunk/utils/oood/oood.rc
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue May 29 20:00:22 CEST 2007
Author: jacek
Date: Tue May 29 20:00:21 2007
New Revision: 14647
URL: http://svn.erp5.org?rev=14647&view=rev
Log:
Using oood_home and run_dir from config file instead of hardcoded ones.
After starting server, init script checkis for pid file existence
in loop instead of just waiting for predefined period of time
start.py --init removed as its not longer needed
Modified:
erp5/trunk/utils/oood/oood.rc
Modified: erp5/trunk/utils/oood/oood.rc
URL: http://svn.erp5.org/erp5/trunk/utils/oood/oood.rc?rev=14647&r1=14646&r2=14647&view=diff
==============================================================================
--- erp5/trunk/utils/oood/oood.rc (original)
+++ erp5/trunk/utils/oood/oood.rc Tue May 29 20:00:21 2007
@@ -37,8 +37,12 @@
NAME="oood"
USER=oood
-HOME=/var/lib/oood
-RUNDIR=/var/run/oood
+OOOD_CONFIG_FILE=/etc/oood/oood.conf #change this if want to use another config file
+HOME=$(awk -F= ' /^oood_home/ { print $2 }' $OOOD_CONFIG_FILE )
+RUNDIR=$(awk -F= ' /^run_dir/ { print $2 }' $OOOD_CONFIG_FILE )
+MAX_WAIT_TIME=120 #Maksimum time to wait for the server to create pid file
+
+MAX_RETRYS=$(($MAX_WAIT_TIME/5))
LOCKFILE=$RUNDIR/server_pid.lock
PIDFILE=$LOCKFILE
PYTHON=python
@@ -50,29 +54,34 @@
start() {
if [ -f $LOCKFILE ] ; then
- gprintf "Another instance of %s is running (lockfile exists)." "$NAME"
+ gprintf "Another instance of %s is running (lockfile $LOCKFILE exists)." "$NAME"
echo_failure
echo
exit 4
fi
gprintf "Starting %s: " "$NAME"
- # Initialize the Pool
- su --login $USER --command="$PYTHON $HOME/start.py --init > /dev/null 2>&1 /dev/null"
# Start the server in the background
su --login $USER --command="$PYTHON $HOME/runserw.py --start > /dev/null &"
- sleep 10 # Safe sleep to let the server create its lockfile
- # Warning: this trick should be replaced by a stronger mechanism,
- # because under heavy load, the server can take several tenth of
- # seconds to start. This case should be handled in runserw.py script.
- if [ -f $PIDFILE ]; then
- echo_success
- else
- gprintf "%s is not running (no pid file found)." "$NAME"
- su --login $USER --command="$PYTHON $HOME/start.py --flush > /dev/null 2>&1 /dev/null"
- echo_failure
- fi
- echo
+
+ # Waiting for the lock file to be created by the server
+ # We will check file existence at most MAX_RETRYS times, waiting 5 secs.
+ # between retrys.
+
+ RETR_NO=0
+ while [ $RETR_NO -lt $MAX_RETRYS ]; do
+ if [ -f $LOCKFILE ]; then
+ echo_success
+ echo
+ exit 0
+ fi
+ sleep 5
+ RETR_NO=$(($RETR_NO+1))
+ done
+ gprintf "%s is not running (no pid file ${PIDFILE} found)." "$NAME"
+ su --login $USER --command="$PYTHON $HOME/start.py --flush > /dev/null 2>&1 /dev/null"
+ rm -f $LOCKFILE
+ echo_failure
}
@@ -108,6 +117,8 @@
stop)
stop
rm -f /var/lock/subsys/$NAME
+ rm -f $LOCKFILE #sometimes is not removed by runserv.py
+
;;
restart)
More information about the Erp5-report
mailing list