File size: 2,589 Bytes
53c3899
76afa36
 
10f8ea4
76afa36
 
 
 
 
 
 
 
 
10f8ea4
76afa36
 
 
53c3899
76afa36
53c3899
76afa36
 
 
 
 
 
 
53c3899
76afa36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53c3899
 
f0fa4c5
53c3899
f0fa4c5
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Boot sequence for the HF Space: (optionally) the ever-jobs sidecar, then the
# FastAPI + Streamlit app.
#
# ever-jobs is DISABLED by default. Rationale:
#   * It runs a NestJS process that cannot reliably run inside HF Spaces, and
#     the upstream repo currently fails to boot on Node 20 with
#     ERR_MODULE_NOT_FOUND (.../plugin.module — extensionless ESM imports).
#   * Trying to start it spammed a scary stack trace and added an up-to-45s
#     startup wait on EVERY boot, for zero benefit on HF.
#   * The Direct Company ATS source (Greenhouse/Lever/Ashby) + the dedicated
#     scrapers (LinkedIn/Indeed/Glassdoor/Remotive/WWR/Naukri) now cover bulk
#     scraping without the Node sidecar.
#
# To re-enable it (e.g. on a host where Node works), set ENABLE_EVER_JOBS=1.
# To use a REMOTE sidecar, set EVER_JOBS_API_URL=https://your-host (the app
# health-checks that URL directly and never starts a local process).

ENABLE_EVER_JOBS="${ENABLE_EVER_JOBS:-0}"

if [ "$ENABLE_EVER_JOBS" = "1" ] || [ "$ENABLE_EVER_JOBS" = "true" ]; then
    echo "=== Starting ever-jobs API on port 3001 (ENABLE_EVER_JOBS=$ENABLE_EVER_JOBS) ==="
    cd /app/vendor/ever-jobs
    export TS_NODE_TRANSPILE_ONLY=1
    export TS_NODE_COMPILER_OPTIONS='{"module":"commonjs","moduleResolution":"node","esModuleInterop":true,"allowJs":true}'
    npx nest start api > /tmp/ever-jobs.log 2>&1 &
    EVER_JOBS_PID=$!

    echo "Waiting for ever-jobs to be ready (up to 45s)..."
    READY=0
    for i in $(seq 1 22); do
        if curl -sf http://localhost:3001/health > /dev/null 2>&1; then
            echo "ever-jobs ready after ${i}x2s"
            READY=1
            break
        fi
        if ! kill -0 $EVER_JOBS_PID 2>/dev/null; then
            echo "ever-jobs process exited early — see error below:"
            tail -20 /tmp/ever-jobs.log 2>/dev/null
            break
        fi
        sleep 2
    done

    if [ $READY -eq 0 ]; then
        echo "WARNING: ever-jobs did not start — 160+ platforms will be skipped this session."
        echo "         Direct Company ATS + dedicated scrapers still work."
    fi
else
    echo "=== ever-jobs sidecar DISABLED (default) ==="
    echo "    Bulk scraping uses Direct Company ATS (Greenhouse/Lever/Ashby) +"
    echo "    dedicated scrapers (LinkedIn/Indeed/Glassdoor/Remotive/WWR/Naukri)."
    echo "    Set ENABLE_EVER_JOBS=1 to boot the local Node sidecar, or"
    echo "    EVER_JOBS_API_URL=<remote> to use a hosted one."
fi

echo "=== Starting FastAPI + Streamlit (via api_server.py) ==="
cd /app
exec python api_server.py