Spaces:
Sleeping
Sleeping
| # Start ever-jobs NestJS API in background, then Streamlit. | |
| # | |
| # ever-jobs uses extensionless relative imports (.../plugin.module). Under | |
| # Node 20, ESM strict mode rejects these with ERR_MODULE_NOT_FOUND, and the | |
| # old `--experimental-specifier-resolution=node` flag was REMOVED in Node 20. | |
| # Fix: force ts-node to emit CommonJS, where extensionless imports resolve | |
| # fine. We also disable type-checking (transpile-only) for faster, more | |
| # tolerant startup. | |
| # | |
| # If ever-jobs fails anyway, Streamlit still launches and dedicated scrapers | |
| # (LinkedIn/Indeed/Glassdoor/Remotive/WWR/Naukri) keep working β only the | |
| # 160+ "ever-jobs" platforms are skipped that session. | |
| echo "=== Starting ever-jobs API on port 3001 ===" | |
| 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=$! | |
| # Shorter wait β 45s max. ts-node compile on first start usually takes ~20s. | |
| # Don't block Streamlit launch for longer than that even if ever-jobs hangs. | |
| 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 | |
| # Check if the process died early | |
| 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 " Dedicated scrapers (LinkedIn/Indeed/Glassdoor/Remotive/WWR/Naukri) still work." | |
| fi | |
| echo "=== Starting FastAPI + Streamlit (via api_server.py) ===" | |
| cd /app | |
| exec python api_server.py | |