From 15e3f4b1a3bc8c85b7598393d9a5ec73a9c95dc1 Mon Sep 17 00:00:00 2001 From: ronivay Date: Fri, 11 Dec 2020 12:04:12 +0200 Subject: [PATCH] change the waiting for port loop logic and look for logs only after latest installation --- xo-install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xo-install.sh b/xo-install.sh index 69d7d1c..4b5558f 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -30,7 +30,8 @@ PLUGINS="${PLUGINS:-"none"}" REPOSITORY="${REPOSITORY:-"https://github.com/vatesfr/xen-orchestra"}" # set variables not changeable in configfile -TIME=$(date +%Y%d%m%H%M) +TIME=$(date +%Y%m%d%H%M) +LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") LOGFILE="${LOGPATH}/xo-install.log-$TIME" NODEVERSION="12" @@ -681,14 +682,17 @@ function InstallXO { set +eo pipefail trap - ERR INT - timeout 60 bash <<-"EOF" - while [[ -z $(journalctl -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "https\{0,1\}:\/\/\[::\]:$PORT") ]]; do - echo " waiting for port to be open" - sleep 10 - done - EOF + count=0 + limit=6 + servicestatus="$(journalctl --since "$LOGTIME" -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "https\{0,1\}:\/\/\[::\]:$PORT")" + while [[ -z "$servicestatus" ]] && [[ "$count" -lt "$limit" ]]; do + echo " waiting for port to be open" + sleep 10 + servicestatus="$(journalctl --since "$LOGTIME" -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "https\{0,1\}:\/\/\[::\]:$PORT")" + (( count++ )) + done - if [[ $(journalctl -u xo-server | sed -n 'H; /Starting XO Server/h; ${g;p;}' | grep "https\{0,1\}:\/\/\[::\]:$PORT") ]]; then + if [[ ! -z "$servicestatus" ]]; then echo echo -e " ${COLOR_GREEN}WebUI started in port $PORT. Make sure you have firewall rules in place to allow access.${COLOR_N}" if [[ "$TASK" == "Installation" ]]; then @@ -708,7 +712,7 @@ function InstallXO { echo "$TASK failed" >> $LOGFILE echo "xo-server service log:" >> $LOGFILE echo "" >> $LOGFILE - journalctl -u xo-server -n 100 >> $LOGFILE + journalctl --since "$LOGTIME" -u xo-server >> $LOGFILE echo echo "Control xo-server service with systemctl for stop/start/restart etc." exit 1