From 81c4abfed8ddaa05a1b36834cd1c4dd8d258013f Mon Sep 17 00:00:00 2001 From: James Laska Date: Tue, 14 Jul 2015 11:14:13 -0400 Subject: [PATCH] Correct initscript order and mongod detection In addition to starting and stopping mongod in the correct order, the check for determining whether mongod is required needs to happen when the service is managed. --- tools/scripts/ansible-tower-service | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/scripts/ansible-tower-service b/tools/scripts/ansible-tower-service index ae52c22aa2..ed10537bf9 100755 --- a/tools/scripts/ansible-tower-service +++ b/tools/scripts/ansible-tower-service @@ -13,16 +13,29 @@ fi service_action() { SERVICES=$TOWER_SERVICES - # Should MongoDB be managed by this script? - # We only manage MongoDB if the license uses it. - tower-manage uses_mongo - if [ $? == 0 && ${1} == start ]; then - SERVICES="$SERVICES mongod" - elif [ $? == 0 && ${1} == stop ]; then - SERVICES="mongod $SERVICES" - fi + # When determining whether mongod is required, postgres is required. The + # following ensures mongod is started after postgres, and stopped before + # postgres. + case ${1} in + start|status) + SERVICES="$SERVICES mongod" + ;; + stop) + SERVICES="mongod $SERVICES" + ;; + esac for svc in ${SERVICES}; do + + # Determine whether mongod is needed + if [[ ${svc} == mongod ]]; then + tower-manage uses_mongo 2> /dev/null >/dev/null + # if mongod is not required, break + if [ $? -ne 0 ]; then + break + fi + fi + service ${svc} $1 this_return=$? if [ $this_return -gt $worst_return ]; then