8900 commited on
Update entrypoint.sh
Browse files- entrypoint.sh +30 -6
entrypoint.sh
CHANGED
|
@@ -2,7 +2,13 @@
|
|
| 2 |
|
| 3 |
# OpenClaw HF Spaces - Production Entrypoint
|
| 4 |
|
| 5 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# ββ resolve writable home βββββββββββ
|
| 8 |
|
|
@@ -33,7 +39,10 @@ done
|
|
| 33 |
|
| 34 |
export HF_TOKEN="${HF_TOKEN:-}"
|
| 35 |
|
| 36 |
-
# ββ run setup
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
echo "[entrypoint] Running setupβ¦"
|
| 39 |
node /app/spaces/huggingface/setup-hf-config.mjs || true
|
|
@@ -45,16 +54,31 @@ if [ -f /app/security-check.sh ]; then
|
|
| 45 |
sh /app/security-check.sh || true
|
| 46 |
fi
|
| 47 |
|
| 48 |
-
# ββ start sync manager in background β
|
| 49 |
|
| 50 |
if [ -f /app/hf-sync-manager.mjs ]; then
|
| 51 |
(node /app/hf-sync-manager.mjs &)
|
| 52 |
echo "[entrypoint] Sync manager started"
|
| 53 |
fi
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
--allow-unconfigured \
|
| 59 |
--bind lan \
|
| 60 |
-
--port 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
# OpenClaw HF Spaces - Production Entrypoint
|
| 4 |
|
| 5 |
+
#
|
| 6 |
+
# KEY: gateway runs in a while loop.
|
| 7 |
+
# When OpenClaw does βfull process restartβ (on config save),
|
| 8 |
+
# the gateway process exits but the container stays alive.
|
| 9 |
+
# The loop catches the exit and restarts the gateway in ~1 second.
|
| 10 |
+
# This eliminates: container crash, 1005/1006 permanent errors,
|
| 11 |
+
# settings overwrite (setup only runs once per container lifetime).
|
| 12 |
|
| 13 |
# ββ resolve writable home βββββββββββ
|
| 14 |
|
|
|
|
| 39 |
|
| 40 |
export HF_TOKEN="${HF_TOKEN:-}"
|
| 41 |
|
| 42 |
+
# ββ run setup ONCE ββββββββββββββββββββ
|
| 43 |
+
|
| 44 |
+
# setup.mjs uses patch mode: if openclaw.json exists, only update
|
| 45 |
+
# auth/env.vars/channels, never overwrite user settings.
|
| 46 |
|
| 47 |
echo "[entrypoint] Running setupβ¦"
|
| 48 |
node /app/spaces/huggingface/setup-hf-config.mjs || true
|
|
|
|
| 54 |
sh /app/security-check.sh || true
|
| 55 |
fi
|
| 56 |
|
| 57 |
+
# ββ start sync manager ONCE in background ββββββ
|
| 58 |
|
| 59 |
if [ -f /app/hf-sync-manager.mjs ]; then
|
| 60 |
(node /app/hf-sync-manager.mjs &)
|
| 61 |
echo "[entrypoint] Sync manager started"
|
| 62 |
fi
|
| 63 |
|
| 64 |
+
# ββ gateway loop ββββββββββββββ
|
| 65 |
+
|
| 66 |
+
# OpenClaw βfull process restartβ exits the gateway process (code 0).
|
| 67 |
+
# Without this loop: container exits -> HF stops container -> crash.
|
| 68 |
+
# With this loop: exit caught -> restart in 1s -> container stays alive.
|
| 69 |
+
# Users see: brief 1005/1006 disconnect -> auto-reconnect in ~5-10s.
|
| 70 |
+
|
| 71 |
+
echo "[entrypoint] Starting gateway loopβ¦"
|
| 72 |
|
| 73 |
+
while true; do
|
| 74 |
+
echo "[entrypoint] Gateway startingβ¦"
|
| 75 |
+
|
| 76 |
+
node /app/openclaw.mjs gateway \
|
| 77 |
--allow-unconfigured \
|
| 78 |
--bind lan \
|
| 79 |
+
--port 7860
|
| 80 |
+
|
| 81 |
+
EXIT_CODE=$?
|
| 82 |
+
echo "[entrypoint] Gateway exited (code $EXIT_CODE) - restarting in 2sβ¦"
|
| 83 |
+
sleep 2
|
| 84 |
+
done
|