Spaces:
Sleeping
Sleeping
Upload scripts/entrypoint.sh with huggingface_hub
Browse files- scripts/entrypoint.sh +39 -76
scripts/entrypoint.sh
CHANGED
|
@@ -1,79 +1,42 @@
|
|
| 1 |
-
#!/bin/
|
| 2 |
-
set -e
|
| 3 |
-
|
| 4 |
-
BOOT_START=$(date +%s)
|
| 5 |
-
|
| 6 |
-
echo "[entrypoint] OpenClaw HuggingFace Spaces Entrypoint"
|
| 7 |
-
echo "[entrypoint] ======================================="
|
| 8 |
-
|
| 9 |
-
# ββ DNS pre-resolution (background β non-blocking) βββββββββββββββββββββββ
|
| 10 |
-
# Resolves WhatsApp domains via DoH for dns-fix.cjs to consume.
|
| 11 |
-
# Telegram connectivity is handled by API base auto-probe in sync_hf.py.
|
| 12 |
-
echo "[entrypoint] Starting DNS resolution in background..."
|
| 13 |
-
python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json 2>&1 &
|
| 14 |
-
DNS_PID=$!
|
| 15 |
-
echo "[entrypoint] DNS resolver PID: $DNS_PID"
|
| 16 |
|
| 17 |
-
|
| 18 |
-
if [ -n "$NODE_MEMORY_LIMIT" ]; then
|
| 19 |
-
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--max-old-space-size=$NODE_MEMORY_LIMIT"
|
| 20 |
-
echo "[entrypoint] Node.js memory limit: ${NODE_MEMORY_LIMIT}MB"
|
| 21 |
-
fi
|
| 22 |
-
|
| 23 |
-
# Enable Node.js DNS fix (will use resolved file when ready)
|
| 24 |
-
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/dns-fix.cjs"
|
| 25 |
-
|
| 26 |
-
# Enable Telegram API proxy (redirects fetch() to working mirror if needed)
|
| 27 |
-
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/telegram-proxy.cjs"
|
| 28 |
-
|
| 29 |
-
# Enable token redirect + A2A routing + state/agents endpoints (all in one preload)
|
| 30 |
-
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/token-redirect.cjs"
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
echo "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
mkdir -p /app/.openclaw
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
echo "[entrypoint] Build artifacts check:"
|
| 58 |
-
test -f dist/entry.js && echo " OK dist/entry.js" || echo " INFO: dist/entry.js not found (pre-built image may use openclaw.mjs)"
|
| 59 |
-
test -f openclaw.mjs && echo " OK openclaw.mjs" || echo " INFO: openclaw.mjs not found"
|
| 60 |
-
test -f dist/plugin-sdk/index.js && echo " OK dist/plugin-sdk/index.js" || echo " INFO: dist/plugin-sdk/index.js not found"
|
| 61 |
-
echo " Extensions: $(ls extensions/ 2>/dev/null | wc -l | tr -d ' ') found"
|
| 62 |
-
echo " Global extensions link: $(readlink /home/node/.openclaw/extensions 2>/dev/null || echo 'NOT SET')"
|
| 63 |
-
|
| 64 |
-
# Create logs directory
|
| 65 |
-
mkdir -p /home/node/logs
|
| 66 |
-
touch /home/node/logs/app.log
|
| 67 |
-
|
| 68 |
-
ENTRYPOINT_END=$(date +%s)
|
| 69 |
-
echo "[TIMER] Entrypoint (before sync_hf.py): $((ENTRYPOINT_END - BOOT_START))s"
|
| 70 |
-
|
| 71 |
-
# ββ Set version from build artifact ββββββββββββββββββββββββββββββββββββββββ
|
| 72 |
-
if [ -f /app/openclaw/.version ]; then
|
| 73 |
-
export OPENCLAW_VERSION=$(cat /app/openclaw/.version)
|
| 74 |
-
echo "[entrypoint] OpenClaw version: $OPENCLAW_VERSION"
|
| 75 |
-
fi
|
| 76 |
-
|
| 77 |
-
# ββ Start OpenClaw via sync_hf.py (directly on port 7860, no proxy) βββββββ
|
| 78 |
-
echo "[entrypoint] Starting OpenClaw via sync_hf.py..."
|
| 79 |
-
exec python3 -u /home/node/scripts/sync_hf.py
|
|
|
|
| 1 |
+
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
set -e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# Wait for DNS resolution
|
| 6 |
+
echo "Waiting for DNS resolution..."
|
| 7 |
+
for i in {1..30}; do
|
| 8 |
+
if nslookup cain-voice.hf.space > /dev/null 2>&1; then
|
| 9 |
+
break
|
| 10 |
+
fi
|
| 11 |
+
sleep 1
|
| 12 |
+
done
|
| 13 |
+
|
| 14 |
+
# Set environment variables
|
| 15 |
+
export OPENCLAW_HOST="http://localhost:7860"
|
| 16 |
+
export OPENCLAW_VOICE="default"
|
| 17 |
+
export OPENCLAW_LANGUAGE="en"
|
| 18 |
+
|
| 19 |
+
# Create necessary directories
|
| 20 |
mkdir -p /app/.openclaw
|
| 21 |
+
mkdir -p /app/output
|
| 22 |
+
|
| 23 |
+
# Start OpenClaw in the background
|
| 24 |
+
echo "Starting OpenClaw..."
|
| 25 |
+
cd /app
|
| 26 |
+
nohup python -m openclaw.server --host 0.0.0.0 --port 7860 > openclaw.log 2>&1 &
|
| 27 |
+
OPENCLAW_PID=$!
|
| 28 |
+
|
| 29 |
+
# Wait for OpenClaw to start
|
| 30 |
+
echo "Waiting for OpenClaw to initialize..."
|
| 31 |
+
for i in {1..30}; do
|
| 32 |
+
if curl -f $OPENCLAW_HOST > /dev/null 2>&1; then
|
| 33 |
+
echo "OpenClaw is ready!"
|
| 34 |
+
break
|
| 35 |
+
fi
|
| 36 |
+
sleep 1
|
| 37 |
+
done
|
| 38 |
+
|
| 39 |
+
# Start the sync process
|
| 40 |
+
echo "Starting Cain..."
|
| 41 |
+
cd /app
|
| 42 |
+
python scripts/sync_hf.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|