diff --git a/start_server.sh b/start_server.sh index 87c7702..4763895 100755 --- a/start_server.sh +++ b/start_server.sh @@ -129,21 +129,19 @@ echo "launching PyWorker server" [ -e "$MODEL_LOG" ] && cat "$MODEL_LOG" >> "$MODEL_LOG.old" && : > "$MODEL_LOG" -# Run the worker in foreground so we can detect non-zero exit and report it +set +e python3 -m "workers.$BACKEND.server" |& tee -a "$PYWORKER_LOG" -STATUS=$? +PY_STATUS=${PIPESTATUS[0]} +set -e -if [ $STATUS -ne 0 ]; then - echo "PyWorker exited with status $STATUS; notifying autoscaler..." - - ERROR_MSG="PyWorker exited: code ${STATUS}" +if [ "${PY_STATUS}" -ne 0 ]; then + echo "PyWorker exited with status ${PY_STATUS}; notifying autoscaler..." + ERROR_MSG="PyWorker exited: code ${PY_STATUS}" MTOKEN="${MASTER_TOKEN:-}" VERSION="${PYWORKER_VERSION:-0}" - # Comma-separated REPORT_ADDR is supported IFS=',' read -r -a REPORT_ADDRS <<< "${REPORT_ADDR}" for addr in "${REPORT_ADDRS[@]}"; do - # minimal, schema-compatible payload curl -sS -X POST -H 'Content-Type: application/json' \ -d "$(cat <