# HG changeset patch # User Severin Gehwolf # Date 1500652882 -7200 # Node ID 0a17affdae81336ba8a6538bb99d7213ec8a94ee # Parent c69fd8f97d50292549e796ed1e27c32bfbcf86c6 Fix error checking in thermostat-ng.sh Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024263.html diff -r c69fd8f97d50 -r 0a17affdae81 thermostat-ng.sh --- a/thermostat-ng.sh Tue Jul 18 18:46:20 2017 +0200 +++ b/thermostat-ng.sh Fri Jul 21 18:01:22 2017 +0200 @@ -63,11 +63,12 @@ local max_attempts=40 while [ $max_attempts -gt 0 ]; do if grep -q "$expected_msg" "$log_file"; then - break + return 0 fi sleep 1 max_attempts=$(( $max_attempts - 1 )) done + return 1 } # Start/Stop mongodb @@ -88,12 +89,14 @@ start_web_gateway() { local error=0 + local fail_msg="Failed to start web-gateway" echo "Starting web-gateway ..." $WEB_GATEWAY_ROOT/distribution/target/image/bin/thermostat-web-gateway.sh > "$GW_LOG_FILE" 2>&1 & error=$? echo $! > "$GW_PID_FILE" - check_success_msg $error "Failed to start web-gateway" + check_success_msg $error $fail_msg wait_for_ready "Server:main: Started" "$GW_LOG_FILE" + check_success_msg $? $fail_msg echo "web-gateway started." echo "PID file: $GW_PID_FILE" echo "Log file: $GW_LOG_FILE" @@ -131,11 +134,13 @@ } start_agent() { + local fail_msg="Failed to start agent" config_agent echo "Starting agent ..." $AGENT_ROOT/distribution/target/image/bin/thermostat -J-Dthermostat.agent.verbose=true -Tbg "$AGENT_PID_FILE" > "$AGENT_LOG_FILE" 2>&1 - check_success_msg $? "Failed to start agent" + check_success_msg $? $fail_msg wait_for_ready "Agent started" "$AGENT_LOG_FILE" + check_success_msg $? $fail_msg echo "agent started." echo "PID file: $AGENT_PID_FILE" echo "Log file: $AGENT_LOG_FILE"