| #!/bin/sh
|
| set -e
|
|
|
| BOOT_START=$(date +%s)
|
|
|
| echo "[entrypoint] OpenClaw HuggingFace Spaces Entrypoint"
|
| echo "[entrypoint] ======================================="
|
|
|
|
|
|
|
|
|
| echo "[entrypoint] Starting DNS resolution in background..."
|
| python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json 2>&1 &
|
| DNS_PID=$!
|
| echo "[entrypoint] DNS resolver PID: $DNS_PID"
|
|
|
|
|
| if [ -n "$NODE_MEMORY_LIMIT" ]; then
|
| export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--max-old-space-size=$NODE_MEMORY_LIMIT"
|
| echo "[entrypoint] Node.js memory limit: ${NODE_MEMORY_LIMIT}MB"
|
| fi
|
|
|
|
|
| export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/dns-fix.cjs"
|
|
|
|
|
| export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/telegram-proxy.cjs"
|
|
|
|
|
| export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/token-redirect.cjs"
|
|
|
|
|
| SYMLINK_START=$(date +%s)
|
| if [ ! -L /home/node/.openclaw/extensions ]; then
|
| rm -rf /home/node/.openclaw/extensions 2>/dev/null || true
|
| ln -s /app/openclaw/extensions /home/node/.openclaw/extensions
|
| echo "[entrypoint] Created extensions symlink -> /app/openclaw/extensions"
|
| fi
|
| echo "[TIMER] Extensions symlink: $(($(date +%s) - SYMLINK_START))s"
|
|
|
|
|
| if [ -d /home/node/.openclaw/credentials/whatsapp ]; then
|
| echo "[entrypoint] Found existing WhatsApp credentials - will use for auto-connect"
|
| fi
|
|
|
|
|
| cd /app/openclaw
|
| echo "[entrypoint] Build artifacts check:"
|
| test -f dist/entry.js && echo " OK dist/entry.js" || echo " INFO: dist/entry.js not found (pre-built image may use openclaw.mjs)"
|
| test -f openclaw.mjs && echo " OK openclaw.mjs" || echo " INFO: openclaw.mjs not found"
|
| test -f dist/plugin-sdk/index.js && echo " OK dist/plugin-sdk/index.js" || echo " INFO: dist/plugin-sdk/index.js not found"
|
| echo " Extensions: $(ls extensions/ 2>/dev/null | wc -l | tr -d ' ') found"
|
| echo " Global extensions link: $(readlink /home/node/.openclaw/extensions 2>/dev/null || echo 'NOT SET')"
|
|
|
|
|
| mkdir -p /home/node/logs
|
| touch /home/node/logs/app.log
|
|
|
| ENTRYPOINT_END=$(date +%s)
|
| echo "[TIMER] Entrypoint (before sync_hf.py): $((ENTRYPOINT_END - BOOT_START))s"
|
|
|
|
|
| if [ -f /app/openclaw/.version ]; then
|
| export OPENCLAW_VERSION=$(cat /app/openclaw/.version)
|
| echo "[entrypoint] OpenClaw version: $OPENCLAW_VERSION"
|
| fi
|
|
|
|
|
| echo "[entrypoint] Starting OpenClaw via sync_hf.py..."
|
| exec python3 -u /home/node/scripts/sync_hf.py
|
|
|