上一次部署里旧 worker 没随 master 退出,一直占着 8123。新 master 启动、 打印 started、然后什么都不服务——日志每一行看起来都正常,站点却是挂的。 - stop.sh 等进程真正退出,超时后 -9 - start.sh 停完等端口释放,起来后 curl 健康检查通过才算成功,否则返回非零 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
20 lines
571 B
Bash
Executable File
20 lines
571 B
Bash
Executable File
#!/bin/sh
|
|
APP="$(cd "$(dirname "$0")" && pwd)"
|
|
GUNICORN="$APP/backend/.venv/bin/gunicorn"
|
|
|
|
if [ -f "$APP/app.pid" ]; then
|
|
kill "$(cat "$APP/app.pid")" 2>/dev/null && echo "stopped $(cat "$APP/app.pid")"
|
|
rm -f "$APP/app.pid"
|
|
fi
|
|
|
|
# The master's workers do not always go with it, and a surviving worker keeps
|
|
# :8123 bound — which looks exactly like a healthy start that serves nothing.
|
|
i=0
|
|
while [ $i -lt 15 ]; do
|
|
pgrep -f "$GUNICORN" >/dev/null 2>&1 || exit 0
|
|
sleep 1
|
|
i=$((i + 1))
|
|
done
|
|
pkill -9 -f "$GUNICORN" 2>/dev/null
|
|
echo "force-stopped leftover workers"
|