Spaces:
Sleeping

File size: 1,176 Bytes
906a253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Hugging Face Spaces entrypoint
# This script starts the MEXC SMC Scanner as a containerized Space service.

set -euo pipefail

# Detect if running inside a container and auto-set PORT
if [[ -n "${HF_SPACE:-}" ]]; then
    echo "[HF Space] Running in Hugging Face Space"
    export PORT="${PORT:-7860}"
fi

# Guard: Telegram credentials are required
if [[ -z "${TELEGRAM_BOT_TOKEN:-}" || -z "${TELEGRAM_CHAT_ID:-}" ]]; then
    echo "=============================================="
    echo "  SETUP REQUIRED"
    echo "=============================================="
    echo "Add these secrets in your Hugging Face Space settings:"
    echo "  - TELEGRAM_BOT_TOKEN"
    echo "  - TELEGRAM_CHAT_ID"
    echo ""
    echo "Restart the Space after adding them."
    echo "=============================================="
    # Don't exit — keep the server running so the UI is visible
    # The scanner will log warnings on every cycle until creds are set
fi

# Upgrade pip in background so first request is fast
python -m pip install --upgrade pip -q &

cd /app
python preflight_check.py || true

exec uvicorn app:app --host 0.0.0.0 --port "${PORT:-7860}"