Files
kennethreitz 2ab3dfa142 Add static site generation with nginx + hardened FastAPI sidecar
Pre-render ~1,277 high-traffic HTML pages (homepage, books, chapters)
at build time and serve them directly via nginx. All other routes
(verses, search, API, PDFs, Strong's) fall through to a FastAPI
sidecar. If the sidecar crashes, nginx continues serving static
pages and health checks.

Also harden the FastAPI app against the memory/crash issues:
- Switch from bare uvicorn to gunicorn with uvicorn workers
- Add --max-requests worker recycling to prevent memory leaks
- Add --timeout to kill hung workers
- Add per-IP rate limiting middleware (10 req/s, burst of 50)
- Add request timeout middleware (30s max per request)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:59:34 -05:00

51 lines
949 B
TOML

# fly.toml app configuration file generated for kjvstudy on 2025-05-26T12:55:54-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'kjvstudy'
primary_region = 'iad'
[deploy]
strategy = "bluegreen"
[build]
dockerfile = "Dockerfile.static"
[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = 'suspend'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[http_service.concurrency]
type = "requests"
hard_limit = 250
soft_limit = 200
# Health check endpoint
[[http_service.checks]]
interval = "15s"
timeout = "10s"
grace_period = "30s"
method = "GET"
path = "/health"
[[vm]]
memory = '2gb'
cpu_kind = 'shared'
cpus = 2
[env]
# Production optimizations
PYTHONUNBUFFERED = "1"
PYTHONDONTWRITEBYTECODE = "1"
# Lazy-load interlinear data to reduce memory usage
PRELOAD_INTERLINEAR = "false"
# Sidecar workers (gunicorn)
SIDECAR_WORKERS = "1"