Add a service_check function
There is no function to check if the services invoked by devstack are
running well or not. We could use the function to check their status
and print them at the end of devstack running.
Change-Id: I845f6b5dddce5cffa7165ec58517f9ae5d8632a6
diff --git a/functions b/functions
index 0911557..85ff420 100644
--- a/functions
+++ b/functions
@@ -684,6 +684,8 @@
function screen_it {
NL=`echo -ne '\015'`
SCREEN_NAME=${SCREEN_NAME:-stack}
+ SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
+
if is_service_enabled $1; then
# Append the service to the screen rc file
screen_rc "$1" "$2"
@@ -699,7 +701,7 @@
screen -S $SCREEN_NAME -p $1 -X log on
ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
fi
- screen -S $SCREEN_NAME -p $1 -X stuff "$2$NL"
+ screen -S $SCREEN_NAME -p $1 -X stuff "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
fi
}
@@ -724,6 +726,47 @@
fi
}
+# Helper to remove the *.failure files under $SERVICE_DIR/$SCREEN_NAME
+# This is used for service_check when all the screen_it are called finished
+# init_service_check
+function init_service_check() {
+ SCREEN_NAME=${SCREEN_NAME:-stack}
+ SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
+
+ if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then
+ mkdir -p "$SERVICE_DIR/$SCREEN_NAME"
+ fi
+
+ rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure
+}
+
+# Helper to get the status of each running service
+# service_check
+function service_check() {
+ local service
+ local failures
+ SCREEN_NAME=${SCREEN_NAME:-stack}
+ SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
+
+
+ if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then
+ echo "No service status directory found"
+ return
+ fi
+
+ # Check if there is any falure flag file under $SERVICE_DIR/$SCREEN_NAME
+ failures=`ls "$SERVICE_DIR/$SCREEN_NAME"/*.failure 2>/dev/null`
+
+ for service in $failures; do
+ service=`basename $service`
+ service=${service::-8}
+ echo "Error: Service $service is not running"
+ done
+
+ if [ -n "$failures" ]; then
+ echo "More details about the above errors can be found with screen, with ./rejoin-stack.sh"
+ fi
+}
# ``pip install`` the dependencies of the package before ``setup.py develop``
# so pip and not distutils processes the dependency chain