no message
Some checks failed
CI / lint-and-build (push) Successful in 14s
CD / deploy (push) Failing after 12s

This commit is contained in:
2026-06-11 00:39:48 +08:00
parent e3810870c9
commit f86ee1307f
2 changed files with 13 additions and 8 deletions

View File

@@ -51,7 +51,7 @@ jobs:
- name: Verify pid is alive - name: Verify pid is alive
run: | run: |
sleep 2 sleep 5
PID_FILE="$DEPLOY_DIR/.pid" PID_FILE="$DEPLOY_DIR/.pid"
if [ ! -f "$PID_FILE" ]; then if [ ! -f "$PID_FILE" ]; then
echo "no .pid file at $PID_FILE" >&2 echo "no .pid file at $PID_FILE" >&2
@@ -60,12 +60,17 @@ jobs:
fi fi
PID=$(cat "$PID_FILE") PID=$(cat "$PID_FILE")
echo "pid=$PID" echo "pid=$PID"
if ! kill -0 "$PID" 2>/dev/null; then for i in 1 2 3; do
echo "pid $PID not alive" >&2 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 sudo -n tail -n 50 "$DEPLOY_DIR/logs/app.log" >&2 || true
exit 1 exit 1
fi
echo "service running, pid=$PID"
- name: HTTP health check - name: HTTP health check
run: | run: |

2
run.sh
View File

@@ -8,7 +8,7 @@ if [ "$(id -u)" -ne 0 ]; then
fi fi
mkdir -p logs 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=$! PID=$!
disown "$PID" 2>/dev/null || true disown "$PID" 2>/dev/null || true
echo "$PID" > .pid echo "$PID" > .pid