diff --git a/.gitea/workflows/cd.yml b/.gitea/workflows/cd.yml index 3aceb6d..a6b690a 100644 --- a/.gitea/workflows/cd.yml +++ b/.gitea/workflows/cd.yml @@ -51,7 +51,7 @@ jobs: - name: Verify pid is alive run: | - sleep 2 + sleep 5 PID_FILE="$DEPLOY_DIR/.pid" if [ ! -f "$PID_FILE" ]; then echo "no .pid file at $PID_FILE" >&2 @@ -60,12 +60,17 @@ jobs: fi PID=$(cat "$PID_FILE") echo "pid=$PID" - if ! kill -0 "$PID" 2>/dev/null; then - echo "pid $PID not alive" >&2 - sudo -n tail -n 50 "$DEPLOY_DIR/logs/app.log" >&2 || true - exit 1 - fi - echo "service running, pid=$PID" + for i in 1 2 3; do + if kill -0 "$PID" 2>/dev/null; then + echo "service running, pid=$PID (attempt $i)" + exit 0 + fi + echo "attempt $i: pid $PID not alive yet, retrying..." + sleep 2 + done + echo "pid $PID not alive after 3 attempts" >&2 + sudo -n tail -n 50 "$DEPLOY_DIR/logs/app.log" >&2 || true + exit 1 - name: HTTP health check run: | diff --git a/run.sh b/run.sh index dcd703f..f38c4f0 100644 --- a/run.sh +++ b/run.sh @@ -8,7 +8,7 @@ if [ "$(id -u)" -ne 0 ]; then fi mkdir -p logs -setsid nohup .venv/bin/python main.py > logs/app.log 2>&1 < /dev/null & +nohup .venv/bin/python main.py > logs/app.log 2>&1 & PID=$! disown "$PID" 2>/dev/null || true echo "$PID" > .pid