SCRAPE-32: Integrate scraper scheduler in server.js #31

Merged
stephen merged 1 commits from scraper/server-integration into dev 2026-02-08 20:08:43 -07:00

1 Commits

Author SHA1 Message Date
e39a2643b9 Integrate scraper scheduler and index creation into server.js startup
All checks were successful
CI/CD Pipeline - Apartment API / Scan Dependencies (pull_request) Successful in 13s
CI/CD Pipeline - Apartment API / Lint & Test (pull_request) Successful in 44s
CI/CD Pipeline - Apartment API / Send Webhook Notification (pull_request) Successful in 2s
CI/CD Pipeline - Apartment API / Build & Push Image (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Deploy to Production (pull_request) Has been skipped
Add scraper initialization to the connectToMongoDB() startup flow:
- Import createScraperIndexes, initializeScheduler, and
  registerSignalHandlers from their respective service modules
- Create scraper database indexes during MongoDB connection setup
- Conditionally start the cron scheduler when SCRAPER_ENABLED is true
- Register SIGTERM/SIGINT signal handlers for graceful shutdown

All scraper initialization is wrapped in try/catch so failures are
logged but do not prevent the server from starting. This ensures
existing API functionality remains unaffected even if scraper
components encounter errors during startup.

Add 11 integration tests covering startup behavior, error resilience,
SCRAPER_ENABLED guard, and signal handler registration.
2026-02-08 20:05:48 -07:00