Environment Variables¶
Palfrey CLI uses PALFREY_ environment variable prefix.
Core behavior¶
- Click maps CLI options to
PALFREY_*env vars. - CLI flags override env vars.
- Palfrey mirrors
UVICORN_*vars toPALFREY_*when no Palfrey-specific value is set.
Example runtime setup:
from __future__ import annotations
import os
PREFILL = {
"PALFREY_APP": "myservice.main:app",
"PALFREY_HOST": "0.0.0.0",
"PALFREY_PORT": "8000",
"PALFREY_LOG_LEVEL": "info",
}
for key, value in PREFILL.items():
os.environ.setdefault(key, value)
print("Configured environment variables:")
for key in sorted(PREFILL):
print(f"{key}={os.environ[key]}")
Common examples¶
export PALFREY_APP=main:app
export PALFREY_HOST=0.0.0.0
export PALFREY_PORT=8000
export PALFREY_LOG_LEVEL=info
palfrey
Uvicorn compatibility bridge example:
export UVICORN_HOST=0.0.0.0
export UVICORN_PORT=8000
palfrey main:app
High-value variables to set explicitly¶
PALFREY_APPPALFREY_HOSTPALFREY_PORTPALFREY_WORKERSPALFREY_LOG_LEVELPALFREY_FORWARDED_ALLOW_IPS
Environment-specific recommendations¶
Development¶
Use env vars for convenience, but keep final startup command visible in scripts.
CI¶
Pin all runtime-critical values explicitly for reproducibility.
Production¶
Keep secrets out of CLI arguments and logs. Use secret stores or secure env injection.
Plain-language summary¶
Environment variables are a convenient way to parameterize startup without editing code.