On 04/25/2011 02:31 PM, Mo Morsi wrote:
---
recipes/aeolus_recipe/templates/deltacloud-core | 46 +++++++++++++++-------
1 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/recipes/aeolus_recipe/templates/deltacloud-core
b/recipes/aeolus_recipe/templates/deltacloud-core
index d5cd141..8cc998a 100644
--- a/recipes/aeolus_recipe/templates/deltacloud-core
+++ b/recipes/aeolus_recipe/templates/deltacloud-core
@@ -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() {
ACK. Normally, I'd say that the addition of the PID test could be in a
separate commit just so each change is distinct but both changes seem ok
to me.