Running the application¶
The patera command finds your application class automatically: it looks for the class
decorated with @app in app/__init__.py, app/app.py, app/main.py, ... Use
--app module:Class or the PATERA_IMPORT environment variable to point at it explicitly, and
PATERA_APP_PACKAGE if your package is not called app.
| Command | Description |
|---|---|
patera dev [--app app:App] [--env-file .env] |
Development server (Uvicorn) with auto-reload. Loads .env, .env.dev or .env.local if no file is given. Host and port from PATERA_HOST/PATERA_PORT (default localhost:3000). |
patera prod [--app app:App] [--env-file .env.prod] |
Production server (Granian, installed with the prod extra), DEBUG is forced off. Only an environment file given with --env-file is loaded. Host and port from PATERA_HOST/PATERA_PORT (default 0.0.0.0:80), event loop from PATERA_LOOP. |
patera cli Controller:command [args...] |
Runs a CLI command. |
patera agents [codex\|claude\|all] |
Generates coding-agent instructions and Patera skills without loading an application. |
patera test [--env-file FILE] [pytest args...] |
Runs pytest after loading the test environment file (.env.test when the project has one). See Testing. |
Environment files¶
patera devand application CLI commands load an explicit--env-file, or search.env,.env.devand.env.localin that order.patera prodloads only an environment file named with--env-file.patera testloads.env.testwhen present; an explicit--env-filemust exist.- Values already present in the process environment win over values from the file.
Address¶
The address is resolved in this order:
PATERA_HOST/PATERA_PORTenvironment variables,- defaults set on your configuration class (
HOST,PORT), - launcher defaults:
localhost:3000fordev,0.0.0.0:80forprod.
In production, localhost is mapped to 0.0.0.0. Configure the deployment address explicitly.
Other ASGI servers¶
The application class is an ASGI application factory, so any ASGI server works:
Keep lifespan enabled
Startup and shutdown hooks (database connections, schedulers, caches, ...) depend on the ASGI
lifespan protocol. Simply calling App() does not start resource hooks.
See Deployment for production advice.