32 lines
1.0 KiB
Bash
32 lines
1.0 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# Start HTTP→SOCKS5 proxy bridge if SOCKS5 upstream is configured
|
|
if [ -n "$SOCKS5_PROXY_HOST" ]; then
|
|
echo "[entrypoint] Starting proxy bridge (HTTP :8899 → SOCKS5 $SOCKS5_PROXY_HOST:${SOCKS5_PROXY_PORT:-1002})..."
|
|
if [ -z "$IAAI_PROXY_SERVER" ]; then
|
|
export IAAI_PROXY_SERVER="http://127.0.0.1:8899"
|
|
elif [ "$IAAI_PROXY_SERVER" = "http://localhost:8899" ]; then
|
|
export IAAI_PROXY_SERVER="http://127.0.0.1:8899"
|
|
fi
|
|
echo "[entrypoint] Using browser proxy: $IAAI_PROXY_SERVER"
|
|
python -m iaai_scraper.proxy_bridge &
|
|
BRIDGE_PID=$!
|
|
sleep 1
|
|
if ! kill -0 $BRIDGE_PID 2>/dev/null; then
|
|
echo "[entrypoint] ERROR: iaai_scraper.proxy_bridge failed to start"
|
|
exit 1
|
|
fi
|
|
echo "[entrypoint] Proxy bridge started (PID $BRIDGE_PID)"
|
|
fi
|
|
|
|
# IAAI blocks headless Chromium on Linux; run headed via Xvfb virtual display
|
|
export DISPLAY=:99
|
|
export IAAI_HEADLESS=false
|
|
Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp &
|
|
XVFB_PID=$!
|
|
sleep 0.5
|
|
echo "[entrypoint] Xvfb started (PID $XVFB_PID, DISPLAY=$DISPLAY)"
|
|
|
|
exec "$@"
|