diff --git a/README.md b/README.md index b360615..3624b29 100644 --- a/README.md +++ b/README.md @@ -589,6 +589,17 @@ This ensures identical prices on: ## Production Deployment +### Required Cron Jobs Summary + +| Job | Frequency | Command | +|-----|-----------|---------| +| TLD Prices | Daily 03:00 UTC | `python scripts/seed_tld_prices.py` | +| Domain Check | Daily 06:00 UTC | Built-in scheduler | +| Auction Scrape | Hourly :30 | Built-in scheduler | +| Price Alerts | Daily 04:00 UTC | Built-in scheduler | + +**Note:** All cron jobs run automatically via APScheduler when the backend is running. External cron is only needed if you disable the built-in scheduler. + ### Docker (Recommended) ```bash @@ -655,13 +666,53 @@ POST https://api.porkbun.com/api/json/v3/pricing/get - ✅ No authentication needed - ✅ Updated daily via scheduler -### Scheduler Jobs +### Scheduler Jobs (Built-in APScheduler) + +The backend includes a built-in scheduler that starts automatically with the application. **No external cron jobs needed!** | Job | Schedule | Description | |-----|----------|-------------| -| **Domain Check** | Configurable (default: daily) | Checks all watched domains | -| **TLD Price Scrape** | Daily at 03:00 UTC | Scrapes current TLD prices | +| **Domain Check** | Daily at configured hour (default: 06:00 UTC) | Checks all watched domains for availability | +| **TLD Price Scrape** | Daily at 03:00 UTC | Scrapes 886+ TLD prices from Porkbun API | | **Price Change Alerts** | Daily at 04:00 UTC | Sends email for price changes >5% | +| **Auction Scrape** | Every hour at :30 | Scrapes domain auctions from ExpiredDomains | + +**Scheduler is enabled by default.** When you run `uvicorn app.main:app`, the scheduler starts automatically via the lifespan handler. + +### External Cron Jobs (Production - Optional) + +If you want more control, you can disable the built-in scheduler and use system cron: + +```bash +# Disable built-in scheduler by setting env var +DISABLE_SCHEDULER=true + +# Add to crontab (crontab -e) +# TLD prices daily at 03:00 UTC +0 3 * * * cd /path/to/pounce/backend && source venv/bin/activate && python scripts/seed_tld_prices.py >> /var/log/pounce/tld_scrape.log 2>&1 + +# Domain check daily at 06:00 UTC +0 6 * * * cd /path/to/pounce/backend && source venv/bin/activate && python -c "import asyncio; from app.scheduler import check_all_domains; asyncio.run(check_all_domains())" >> /var/log/pounce/domain_check.log 2>&1 + +# Auction scrape hourly at :30 +30 * * * * cd /path/to/pounce/backend && source venv/bin/activate && python -c "import asyncio; from app.scheduler import scrape_auctions; asyncio.run(scrape_auctions())" >> /var/log/pounce/auction_scrape.log 2>&1 + +# Price alerts daily at 04:00 UTC +0 4 * * * cd /path/to/pounce/backend && source venv/bin/activate && python -c "import asyncio; from app.scheduler import check_price_changes; asyncio.run(check_price_changes())" >> /var/log/pounce/price_alerts.log 2>&1 +``` + +### PM2 with Scheduler (Recommended for Production) + +The easiest production setup is PM2 which keeps the backend running with its built-in scheduler: + +```bash +cd backend && source venv/bin/activate +pm2 start "uvicorn app.main:app --host 0.0.0.0 --port 8000" --name pounce-api +pm2 save +pm2 startup +``` + +This way, the APScheduler handles all cron jobs automatically. ### Manual Scrape