Uvicorn Server (Legacy)
Deprecated
This module is deprecated. Use Granian instead for HTTP/2 support and better performance.
Application Kit provides a server module for running FastAPI applications with pre-configured uvicorn settings.
Usage
Run your FastAPI application using the server module:
python -m application_kit.server
Command Line Options
| Option | Description | Default |
|---|---|---|
--limit-concurrency |
Maximum concurrent connections before returning HTTP 503 | 0 (unlimited) |
# Limit to 100 concurrent connections
python -m application_kit.server --limit-concurrency 100
Environment Variables
| Variable | Description | Default |
|---|---|---|
DEVELOPMENT |
Enable development mode with auto-reload | no |
WORKERS |
Number of worker processes | 4 |
DEBUG |
Enable debug logging (from Bender config) | - |
Development Mode
Enable hot reloading for development:
DEVELOPMENT=yes python -m application_kit.server
In development mode:
- Auto-reload is enabled (watches
/usr/src/app) - Access logs are enabled
Worker Configuration
Set the number of worker processes:
WORKERS=8 python -m application_kit.server
Configuration
The server reads configuration from:
- Your Bender manifest (
application.json) - Environment variables
Application Discovery
The server expects your FastAPI app at {manifest_name}.main:app.
For example, if your manifest has "name": "my_api", it looks for:
"""Server app discovery example.
The server expects your FastAPI app at {manifest_name}.main:app.
For example, if your manifest has "name": "my_api", it looks for:
"""
from fastapi import FastAPI
app = FastAPI()
Server Settings
The following settings are applied automatically:
| Setting | Value | Notes |
|---|---|---|
| Host | 0.0.0.0 |
Binds to all interfaces |
| Port | 8000 |
Fixed port |
| Log level | info or debug |
Based on DEBUG config |
| Forwarded IPs | * |
Trusts all proxy headers |
| Server header | Disabled | Security hardening |
Concurrency Limiting
Use --limit-concurrency to protect your service from overload:
python -m application_kit.server --limit-concurrency 50
When the limit is reached, new connections receive HTTP 503 (Service Unavailable).
Programmatic Usage
You can also use the configuration programmatically:
"""Server programmatic usage example."""
import uvicorn
from application_kit.server import get_uvicorn_config
config = get_uvicorn_config(limit_concurrency=100)
uvicorn.run(**config)