server.production

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

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.

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.

server.production

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

run_production_server
function
def run_production_server(app: App, host: str = '0.0.0.0', port: int = 8000, workers: int = 0, worker_mode: str = 'auto', *, display: DisplayConfig | None = None, 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, rate_limit_max_tracked_ips: int = 100000, trusted_proxies: tuple[str, ...] = (), forwarded_for_trusted_hops: int = 1, 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 = 'auto', 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, lifecycle_collector: LifecycleCollector | None = None) -> None

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

Environment Variables: PreferAppConfig / CHIRP_*fields for Chirp-owned settings. Whenworkers=0, optional WEB_CONCURRENCYoverrides auto-detect.

Parameters

Name Type Default Description
app App Chirp App instance.
host str '0.0.0.0' Bind address (default: 0.0.0.0 for all interfaces).
port int 8000 Bind port (default: 8000).
workers int 0 Worker count (0 = quota-aware auto-detect from cgroup/host CPUs; see ``chirp.server.workers.resolve_production_workers``).
worker_mode str 'auto'
display DisplayConfig | None None Optional Pounce ``DisplayConfig`` forwarded unchanged as ``ServerConfig.display``. ``None`` leaves Pounce unset behavior intact (env / pyproject / app-hook resolution).
metrics_enabled bool True Enable Prometheus /metrics endpoint.
metrics_path str '/metrics' Path for metrics endpoint (default: /metrics).
rate_limit_enabled bool False Enable per-IP rate limiting.
rate_limit_requests_per_second float 100.0 Sustained rate limit per IP.
rate_limit_burst int 200 Maximum burst capacity per IP.
rate_limit_max_tracked_ips int 100000 Max distinct client IPs the per-IP rate limiter tracks before LRU eviction (limiter memory cap).
trusted_proxies tuple[str, ...] () Reverse-proxy peer IPs/hostnames whose X-Forwarded-For is honored (mapped to pounce ServerConfig.trusted_hosts). Empty (the default) means X-Forwarded-For is ignored entirely; "*" trusts every direct peer (spoofing risk — use only on a locked-down network).
forwarded_for_trusted_hops int 1 Trailing X-Forwarded-For hops to trust when deriving the client IP behind a reverse proxy. Must be >= 1 and only takes effect when trusted_proxies is non-empty (the direct peer must be a trusted proxy); to ignore X-Forwarded-For, leave trusted_proxies empty rather than setting this to 0.
request_queue_enabled bool False Enable request queueing.
request_queue_max_depth int 1000 Maximum queued requests (0 = unlimited).
sentry_dsn str | None None Sentry DSN for error tracking (None = disabled).
sentry_environment str | None None Sentry environment name (e.g., "production").
sentry_release str | None None Release version for Sentry (e.g., "myapp@1.0.0").
sentry_traces_sample_rate float 0.1 Performance monitoring sample rate (0.0-1.0).
reload_timeout float 30.0 Time to wait for workers to drain during hot reload.
otel_endpoint str | None None OpenTelemetry OTLP endpoint (None = disabled).
otel_service_name str 'chirp-app' Service name for OpenTelemetry traces.
websocket_compression bool True Enable WebSocket permessage-deflate compression.
websocket_max_message_size int 10485760 Maximum WebSocket message size (bytes).
lifecycle_logging bool True Enable structured lifecycle event logging.
log_format str 'auto' Pounce log format — "auto" (TTY pretty / piped JSON), "text", or "json".
log_level str 'info' Log level (debug, info, warning, error, critical).
max_connections int 1000 Maximum concurrent connections.
backlog int 2048 TCP listen backlog.
keep_alive_timeout float 5.0 Keep-alive connection timeout (seconds).
request_timeout float 30.0 Individual request timeout (seconds).
ssl_certfile str | None None Path to TLS certificate file (enables HTTPS/HTTP2).
ssl_keyfile str | None None Path to TLS private key file.
lifecycle_collector LifecycleCollector | None None Optional Pounce lifecycle collector for startup/shutdown/worker hook event capture.

View source · /home/runner/work/chirp/chirp/site/../src/chirp/server/production.py:1