Module

server.production

Production server with pounce Phase 5 & 6 features.

Starts a pounce production server with multi-worker, metrics, rate limiting, request queueing, error tracking, and zero-downtime hot reload.

Functions

run_production_server 29 None
Run chirp app in production mode with pounce Phase 5 & 6 features. **Environme…
def run_production_server(app: App, host: str = '0.0.0.0', port: int = 8000, workers: int = 0, *, metrics_enabled: bool = True, metrics_path: str = '/metrics', rate_limit_enabled: bool = False, rate_limit_requests_per_second: float = 100.0, rate_limit_burst: int = 200, request_queue_enabled: bool = False, request_queue_max_depth: int = 1000, sentry_dsn: str | None = None, sentry_environment: str | None = None, sentry_release: str | None = None, sentry_traces_sample_rate: float = 0.1, reload_timeout: float = 30.0, otel_endpoint: str | None = None, otel_service_name: str = 'chirp-app', websocket_compression: bool = True, websocket_max_message_size: int = 10485760, lifecycle_logging: bool = True, log_format: str = 'json', log_level: str = 'info', max_connections: int = 1000, backlog: int = 2048, keep_alive_timeout: float = 5.0, request_timeout: float = 30.0, ssl_certfile: str | None = None, ssl_keyfile: str | None = None) -> None

Run chirp app in production mode with pounce Phase 5 & 6 features.

Environment Variables:

You can also configure via environment variables:

  • WORKERS: Worker count
  • METRICS_ENABLED: Enable metrics (true/false)
  • RATE_LIMIT_ENABLED: Enable rate limiting (true/false)
  • SENTRY_DSN: Sentry DSN
  • OTEL_ENDPOINT: OpenTelemetry endpoint
Parameters
Name Type Description
app App

Chirp App instance.

host str

Bind address (default: 0.0.0.0 for all interfaces).

Default:'0.0.0.0'
port int

Bind port (default: 8000).

Default:8000
workers int

Worker count (0 = auto-detect from CPU count).

Default:0
metrics_enabled bool

Enable Prometheus /metrics endpoint.

Default:True
metrics_path str

Path for metrics endpoint (default: /metrics).

Default:'/metrics'
rate_limit_enabled bool

Enable per-IP rate limiting.

Default:False
rate_limit_requests_per_second float

Sustained rate limit per IP.

Default:100.0
rate_limit_burst int

Maximum burst capacity per IP.

Default:200
request_queue_enabled bool

Enable request queueing.

Default:False
request_queue_max_depth int

Maximum queued requests (0 = unlimited).

Default:1000
sentry_dsn str | None

Sentry DSN for error tracking (None = disabled).

Default:None
sentry_environment str | None

Sentry environment name (e.g., "production").

Default:None
sentry_release str | None

Release version for Sentry (e.g., "myapp@1.0.0").

Default:None
sentry_traces_sample_rate float

Performance monitoring sample rate (0.0-1.0).

Default:0.1
reload_timeout float

Time to wait for workers to drain during hot reload.

Default:30.0
otel_endpoint str | None

OpenTelemetry OTLP endpoint (None = disabled).

Default:None
otel_service_name str

Service name for OpenTelemetry traces.

Default:'chirp-app'
websocket_compression bool

Enable WebSocket permessage-deflate compression.

Default:True
websocket_max_message_size int

Maximum WebSocket message size (bytes).

Default:10485760
lifecycle_logging bool

Enable structured lifecycle event logging.

Default:True
log_format str

Log format ("json" or "text").

Default:'json'
log_level str

Log level (debug, info, warning, error, critical).

Default:'info'
max_connections int

Maximum concurrent connections.

Default:1000
backlog int

TCP listen backlog.

Default:2048
keep_alive_timeout float

Keep-alive connection timeout (seconds).

Default:5.0
request_timeout float

Individual request timeout (seconds).

Default:30.0
ssl_certfile str | None

Path to TLS certificate file (enables HTTPS/HTTP2).

Default:None
ssl_keyfile str | None

Path to TLS private key file.

Default:None