CoolFace
Apppublic

ckriti/HuggingClaw

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes
entrypoint.sh70 linesDownload Raw Back to scripts
1#!/bin/sh2set -e3 4BOOT_START=$(date +%s)5 6echo "[entrypoint] OpenClaw HuggingFace Spaces Entrypoint"7echo "[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.12echo "[entrypoint] Starting DNS resolution in background..."13python3 /home/node/scripts/dns-resolve.py /tmp/dns-resolved.json 2>&1 &14DNS_PID=$!15echo "[entrypoint] DNS resolver PID: $DNS_PID"16 17# ── Node.js memory limit (only if explicitly set) ─────────────────────────18if [ -n "$NODE_MEMORY_LIMIT" ]; then19  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"21fi22 23# Enable Node.js DNS fix (will use resolved file when ready)24export 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)27export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/telegram-proxy.cjs"28 29# Auto-fill gateway token in Control UI (redirects "/" to "/?token=GATEWAY_TOKEN")30export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require /home/node/scripts/token-redirect.cjs"31 32# ── Extensions symlink ──────────────────────────────────────────────────────33SYMLINK_START=$(date +%s)34if [ ! -L /home/node/.openclaw/extensions ]; then35  rm -rf /home/node/.openclaw/extensions 2>/dev/null || true36  ln -s /app/openclaw/extensions /home/node/.openclaw/extensions37  echo "[entrypoint] Created extensions symlink -> /app/openclaw/extensions"38fi39echo "[TIMER] Extensions symlink: $(($(date +%s) - SYMLINK_START))s"40 41# ── WhatsApp credentials check ──────────────────────────────────────────────42if [ -d /home/node/.openclaw/credentials/whatsapp ]; then43  echo "[entrypoint] Found existing WhatsApp credentials - will use for auto-connect"44fi45 46# ── Build artifacts check ───────────────────────────────────────────────────47cd /app/openclaw48echo "[entrypoint] Build artifacts check:"49test -f dist/entry.js && echo "  OK dist/entry.js" || echo "  WARNING: dist/entry.js missing!"50test -f dist/plugin-sdk/index.js && echo "  OK dist/plugin-sdk/index.js" || echo "  WARNING: dist/plugin-sdk/index.js missing!"51echo "  Extensions: $(ls extensions/ 2>/dev/null | wc -l | tr -d ' ') found"52echo "  Global extensions link: $(readlink /home/node/.openclaw/extensions 2>/dev/null || echo 'NOT SET')"53 54# Create logs directory55mkdir -p /home/node/logs56touch /home/node/logs/app.log57 58ENTRYPOINT_END=$(date +%s)59echo "[TIMER] Entrypoint (before sync_hf.py): $((ENTRYPOINT_END - BOOT_START))s"60 61# ── Set version from build artifact ────────────────────────────────────────62if [ -f /app/openclaw/.version ]; then63  export OPENCLAW_VERSION=$(cat /app/openclaw/.version)64  echo "[entrypoint] OpenClaw version: $OPENCLAW_VERSION"65fi66 67# ── Start OpenClaw via sync_hf.py ─────────────────────────────────────────68echo "[entrypoint] Starting OpenClaw via sync_hf.py..."69exec python3 -u /home/node/scripts/sync_hf.py70