Spaces:
Paused
Paused
feat: update Dockerfile and start.sh to use python3 and enhance startup banner
Browse filesFiles changed (2)
- Dockerfile+1
- start.sh+46-15
8 unmodified lines910111213148 unmodified linesca-certificates \curl \jq \&& rm -rf /var/lib/apt/lists/* \&& uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir huggingface_hub8 unmodified lines91011121314158 unmodified linesca-certificates \curl \jq \python3 \&& rm -rf /var/lib/apt/lists/* \&& uv pip install --python /opt/hermes/.venv/bin/python --no-cache-dir huggingface_hub
2 unmodified lines34567811 unmodified lines20212223242526272829303 unmodified lines34353637383940414243444546474849503 unmodified lines545556575859601 unmodified line6263646566676814 unmodified lines8384858687888993 unmodified lines18318418518618718818953 unmodified lines24324424524624724824925025125225325425525625725825926026126226326410 unmodified lines27527627727827928020 unmodified lines3013023033043053063072 unmodified linesumask 0077APP_DIR="${HUGGINGMESS_APP_DIR:-/opt/huggingmess}"HERMES_HOME="${HERMES_HOME:-/opt/data}"PUBLIC_PORT="${PORT:-7861}"11 unmodified linesexport GATEWAY_HEALTH_URL="${GATEWAY_HEALTH_URL:-http://127.0.0.1:${GATEWAY_API_PORT}}"export TELEGRAM_WEBHOOK_PORTif [ -z "${API_SERVER_KEY:-}" ]; thenif [ -n "${GATEWAY_TOKEN:-}" ]; thenexport API_SERVER_KEY="$GATEWAY_TOKEN"elseAPI_SERVER_KEY="$(python - <<'PY'import secretsprint(secrets.token_urlsafe(32))PY3 unmodified linesfifiecho ""echo " =========================================="echo " HuggingMess Hermes Gateway"echo " =========================================="echo ""mkdir -p "$HERMES_HOME"/{cron,sessions,logs,hooks,memories,skills,skins,plans,workspace,home}if [ -n "${HF_TOKEN:-}" ]; thenecho "Restoring Hermes state from HF Dataset..."python "$APP_DIR/hermes-sync.py" restore || trueelseecho "HF_TOKEN not set - dataset persistence is disabled."fi3 unmodified linesif [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ] || [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; thenexport CLOUDFLARE_PROXY_DEBUG="${CLOUDFLARE_PROXY_DEBUG:-false}"echo "Preparing Cloudflare Telegram proxy..."python "$APP_DIR/cloudflare-proxy-setup.py" || trueif [ -f "$CF_PROXY_ENV_FILE" ]; then. "$CF_PROXY_ENV_FILE"fi1 unmodified lineif [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ]; thenecho "Preparing Cloudflare Keepalive worker..."python "$APP_DIR/cloudflare-keepalive-setup.py" || truefiif [ -n "${TELEGRAM_USER_IDS:-}" ] && [ -z "${TELEGRAM_ALLOWED_USERS:-}" ]; then14 unmodified linesexport TELEGRAM_WEBHOOK_SECRETTELEGRAM_WEBHOOK_SECRET="$(cat "$SECRET_FILE")"elseTELEGRAM_WEBHOOK_SECRET="$(python - <<'PY'import secretsprint(secrets.token_hex(32))PY93 unmodified linesexport TELEGRAM_BASE_FILE_URL="${CLOUDFLARE_PROXY_URL}/file/bot"fipython - <<'PY'import osfrom pathlib import Path53 unmodified linespath.chmod(0o600)PYgraceful_shutdown() {echo "Shutting down HuggingMess..."if [ -n "${HF_TOKEN:-}" ]; thenpython "$APP_DIR/hermes-sync.py" sync-once || echo "Warning: shutdown sync failed."fikill $(jobs -p) 2>/dev/null || trueexit 0}trap graceful_shutdown SIGTERM SIGINTnode "$APP_DIR/health-server.js" &HEALTH_PID=$!if [ -n "${WEBHOOK_URL:-}" ]; thenpython - <<'PY' >/dev/null 2>&1 &import json, os, urllib.requestbody = json.dumps({"event": "restart",10 unmodified lines(hermes dashboard --host 127.0.0.1 --insecure 2>&1 | tee -a "$HERMES_HOME/logs/dashboard.log") &DASHBOARD_PID=$!echo "Launching Hermes gateway..."(hermes gateway run 2>&1 | tee -a "$HERMES_HOME/logs/gateway.log") &GATEWAY_PID=$!20 unmodified linesfiif [ -n "${HF_TOKEN:-}" ]; thenpython -u "$APP_DIR/hermes-sync.py" loop &fiwait "$GATEWAY_PID"2 unmodified lines34567891011121311 unmodified lines25262728293031323334353637383940413 unmodified lines454647484950515253545556573 unmodified lines616263646566671 unmodified line6970717273747514 unmodified lines9091929394959693 unmodified lines19019119219319419519619753 unmodified lines25125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329410 unmodified lines30530630730830931031120 unmodified lines3323333343353363373382 unmodified linesumask 0077# ════════════════════════════════════════════════════════════════# HuggingMess — Hermes Gateway for HF Spaces# ════════════════════════════════════════════════════════════════# ── Startup Banner ──APP_DIR="${HUGGINGMESS_APP_DIR:-/opt/huggingmess}"HERMES_HOME="${HERMES_HOME:-/opt/data}"PUBLIC_PORT="${PORT:-7861}"11 unmodified linesexport GATEWAY_HEALTH_URL="${GATEWAY_HEALTH_URL:-http://127.0.0.1:${GATEWAY_API_PORT}}"export TELEGRAM_WEBHOOK_PORTecho ""echo " ╔══════════════════════════════════════════╗"echo " ║ 💬 HuggingMess Hermes Gateway ║"echo " ╚══════════════════════════════════════════╝"echo ""if [ -z "${API_SERVER_KEY:-}" ]; thenif [ -n "${GATEWAY_TOKEN:-}" ]; thenexport API_SERVER_KEY="$GATEWAY_TOKEN"elseAPI_SERVER_KEY="$(python3 - <<'PY'import secretsprint(secrets.token_urlsafe(32))PY3 unmodified linesfifi# ── Setup directories ──mkdir -p "$HERMES_HOME"/{cron,sessions,logs,hooks,memories,skills,skins,plans,workspace,home}# ── Restore workspace/state from HF Dataset ──if [ -n "${HF_TOKEN:-}" ]; thenecho "Restoring Hermes state from HF Dataset..."python3 "$APP_DIR/hermes-sync.py" restore || trueelseecho "HF_TOKEN not set - dataset persistence is disabled."fi3 unmodified linesif [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ] || [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; thenexport CLOUDFLARE_PROXY_DEBUG="${CLOUDFLARE_PROXY_DEBUG:-false}"echo "Preparing Cloudflare Telegram proxy..."python3 "$APP_DIR/cloudflare-proxy-setup.py" || trueif [ -f "$CF_PROXY_ENV_FILE" ]; then. "$CF_PROXY_ENV_FILE"fi1 unmodified lineif [ -n "${CLOUDFLARE_WORKERS_TOKEN:-}" ]; thenecho "Preparing Cloudflare Keepalive worker..."python3 "$APP_DIR/cloudflare-keepalive-setup.py" || truefiif [ -n "${TELEGRAM_USER_IDS:-}" ] && [ -z "${TELEGRAM_ALLOWED_USERS:-}" ]; then14 unmodified linesexport TELEGRAM_WEBHOOK_SECRETTELEGRAM_WEBHOOK_SECRET="$(cat "$SECRET_FILE")"elseTELEGRAM_WEBHOOK_SECRET="$(python3 - <<'PY'import secretsprint(secrets.token_hex(32))PY93 unmodified linesexport TELEGRAM_BASE_FILE_URL="${CLOUDFLARE_PROXY_URL}/file/bot"fi# ── Build config ──python3 - <<'PY'import osfrom pathlib import Path53 unmodified linespath.chmod(0o600)PY# ── Startup Summary ──echo ""echo "Model : ${MODEL_FOR_CONFIG:-unset}"echo "Provider : ${PROVIDER_FOR_CONFIG:-unset}"if [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; thenecho "Telegram : enabled"elseecho "Telegram : not configured"fiif [ -n "${HF_TOKEN:-}" ]; thenecho "Backup : ${BACKUP_DATASET} (every ${SYNC_INTERVAL:-180}s)"elseecho "Backup : disabled"fiif [ -n "${CLOUDFLARE_PROXY_URL:-}" ]; thenecho "Proxy : ${CLOUDFLARE_PROXY_URL}"fiecho "Dashboard : http://127.0.0.1:${DASHBOARD_PORT}"echo "Gateway : http://127.0.0.1:${GATEWAY_API_PORT}"echo ""# ── Trap SIGTERM for graceful shutdown ──graceful_shutdown() {echo "Shutting down HuggingMess..."if [ -n "${HF_TOKEN:-}" ]; thenpython3 "$APP_DIR/hermes-sync.py" sync-once || echo "Warning: shutdown sync failed."fikill $(jobs -p) 2>/dev/null || trueexit 0}trap graceful_shutdown SIGTERM SIGINT# ── Start background services ──node "$APP_DIR/health-server.js" &HEALTH_PID=$!if [ -n "${WEBHOOK_URL:-}" ]; thenpython3 - <<'PY' >/dev/null 2>&1 &import json, os, urllib.requestbody = json.dumps({"event": "restart",10 unmodified lines(hermes dashboard --host 127.0.0.1 --insecure 2>&1 | tee -a "$HERMES_HOME/logs/dashboard.log") &DASHBOARD_PID=$!# ── Launch gateway ──echo "Launching Hermes gateway..."(hermes gateway run 2>&1 | tee -a "$HERMES_HOME/logs/gateway.log") &GATEWAY_PID=$!20 unmodified linesfiif [ -n "${HF_TOKEN:-}" ]; thenpython3 -u "$APP_DIR/hermes-sync.py" loop &fiwait "$GATEWAY_PID"
Dockerfile+1
start.sh+46-15