Spaces:
Running
Running
Fix: Move Cloudflare keepalive setup before health-server to avoid race condition
Browse filesThe health-server was starting before the keepalive setup script finished
writing the status file. This caused a race condition where users would see
"Worker pending or failed" until the setup completed. Now the setup runs
before health-server starts, ensuring the status file exists before any
requests are served.
start.sh
CHANGED
|
@@ -244,6 +244,12 @@ if [ -n "${CLOUDFLARE_PROXY_URL:-}" ] && [ -f /opt/cloudflare-proxy.js ]; then
|
|
| 244 |
export NODE_OPTIONS="${NODE_OPTIONS:-} --require /opt/cloudflare-proxy.js"
|
| 245 |
fi
|
| 246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
# ββ Background HF sync loop ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 248 |
SYNC_PID=""
|
| 249 |
if [ -n "${HF_TOKEN:-}" ]; then
|
|
@@ -261,11 +267,6 @@ fi
|
|
| 261 |
node /opt/healthsrv/health-server.js &
|
| 262 |
HEALTH_PID=$!
|
| 263 |
|
| 264 |
-
if [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ]; then
|
| 265 |
-
echo "Setting up Cloudflare KeepAlive monitor..."
|
| 266 |
-
python3 /opt/cloudflare-keepalive-setup.py || true
|
| 267 |
-
fi
|
| 268 |
-
|
| 269 |
sleep 1
|
| 270 |
|
| 271 |
# ββ Postiz: nginx + PM2 (mirrors upstream CMD `nginx && pnpm run pm2`) βββββββ
|
|
|
|
| 244 |
export NODE_OPTIONS="${NODE_OPTIONS:-} --require /opt/cloudflare-proxy.js"
|
| 245 |
fi
|
| 246 |
|
| 247 |
+
# ββ Cloudflare KeepAlive worker ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 248 |
+
if [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ]; then
|
| 249 |
+
echo "Setting up Cloudflare KeepAlive worker..."
|
| 250 |
+
python3 /opt/cloudflare-keepalive-setup.py || true
|
| 251 |
+
fi
|
| 252 |
+
|
| 253 |
# ββ Background HF sync loop ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 254 |
SYNC_PID=""
|
| 255 |
if [ -n "${HF_TOKEN:-}" ]; then
|
|
|
|
| 267 |
node /opt/healthsrv/health-server.js &
|
| 268 |
HEALTH_PID=$!
|
| 269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
sleep 1
|
| 271 |
|
| 272 |
# ββ Postiz: nginx + PM2 (mirrors upstream CMD `nginx && pnpm run pm2`) βββββββ
|