--- aeolus-conductor.spec.in | 4 ++++ conf/aeolus-conductor | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in index 26297ff..f1b71b9 100644 --- a/aeolus-conductor.spec.in +++ b/aeolus-conductor.spec.in @@ -49,6 +49,10 @@ Requires: condor >= 7.5.6-2dcloud Requires: iwhd Requires: aeolus-configure
+# to ensure the service is actually started +# and is accessible in the init script +Requires: curl + BuildRequires: ruby BuildRequires: ruby-devel BuildRequires: classads-devel >= 1.0 diff --git a/conf/aeolus-conductor b/conf/aeolus-conductor index a7b84a7..9a4bd84 100755 --- a/conf/aeolus-conductor +++ b/conf/aeolus-conductor @@ -26,23 +26,44 @@ THIN_PROG=thin ADDR=127.0.0.1 RETVAL=0
+STARTTIMEOUT=20 + . /etc/init.d/functions
start() { echo -n "Starting aeolus-conductor: " + if [ -f $THIN_PID ] && checkpid `cat $THIN_PID` ; then + echo_failure + echo + echo "Thin is already running" + exit 1 + fi
$THIN_PROG start -c $CONDUCTOR_DIR -l $THIN_LOG -P $THIN_PID \ - -a $ADDR -e $RAILS_ENV --user $AEOLUS_USER --group $AEOLUS_GROUP \ - -d --prefix=$PREFIX -A $ADAPTER + -a $ADDR -e $RAILS_ENV --user $AEOLUS_USER --group $AEOLUS_GROUP \ + -d --prefix=$PREFIX -A $ADAPTER RETVAL=$? - if [ $RETVAL -eq 0 ] && touch $THIN_LOCKFILE ; then - echo_success - echo - else - echo_failure - echo + if [ $RETVAL -eq 0 ] ; then + # wait until we can contact the server + # this bit is based on what the mysql init script does + TIMEOUT="$STARTTIMEOUT" + while [ $TIMEOUT -gt 0 ]; do + /usr/bin/curl --silent http://$ADDR:3000$PREFIX >& /dev/null + RETVAL=$? + if [ $RETVAL -eq 0 ] ; then + touch $THIN_LOCKFILE + echo_success + echo + exit 0 + fi + sleep 1 + let TIMEOUT=${TIMEOUT}-1 + done fi
+ echo_failure + echo + exit 1 }
stop() {