Skip to content

Commit

Permalink
BZ #693369: ensure deltacloud-core is actually running before returni…
Browse files Browse the repository at this point in the history
…ng from init script
  • Loading branch information
movitto committed Apr 25, 2011
1 parent 9752fae commit 5fc85fa
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions recipes/aeolus_recipe/templates/deltacloud-core
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,42 @@ export DELTACLOUD_MOCK_STORAGE=/usr/lib/ruby/gems/1.8/gems/deltacloud-<%= name %

PROG=/usr/bin/deltacloudd

STARTTIMEOUT=20

. /etc/init.d/functions

start() {
echo -n "Starting deltacloud-<%= name %>: "

if test -f $LOCKFILE ; then
echo_success
echo
else
$PROG -i $DRIVER -e $ENV -p $PORT >> $LOGFILE 2>&1 &
RETVAL=$?
echo $! > $PIDFILE
if [ $RETVAL -eq 0 ] && touch $LOCKFILE ; then
echo_success
echo
else
echo_failure
echo
fi
fi
if [ -f $LOCKFILE ] || [ -f $PIDFILE ] && checkpid `cat $PIDFILE` ; then
echo_success
echo
echo "deltacloud-$DRIVER has already been started"
exit 0
fi

$PROG -i $DRIVER -e $ENV -p $PORT >> $LOGFILE 2>&1 &
RETVAL=$?
echo $! > $PIDFILE
if [ $RETVAL -eq 0 ] ; then
TIMEOUT="$STARTTIMEOUT"
while [ $TIMEOUT -gt 0 ]; do
/usr/bin/curl --silent http://localhost:$PORT/api >& /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
touch $LOCKFILE
echo_success
echo
exit 0
fi
sleep 1
let TIMEOUT=${TIMEOUT}-1
done
fi

echo_failure
echo
exit 1
}

stop() {
Expand Down

0 comments on commit 5fc85fa

Please sign in to comment.