Files
oxpanel25/app/run_uvicorn.py
T
2026-04-11 22:07:59 +02:00

40 lines
866 B
Python

import os
import uvicorn
def build_config() -> dict:
debug = os.getenv("DEBUG", "true").lower() == "true"
config = {
"host": os.getenv("UVICORN_HOST", "0.0.0.0"),
"port": int(os.getenv("UVICORN_PORT", "8000")),
"loop": "asyncio",
"ws": "websockets",
"proxy_headers": True,
"forwarded_allow_ips": "*",
"log_level": "debug" if debug else "info",
"access_log": True,
}
if debug:
config.update(
{
"reload": True,
"reload_dirs": ["."],
"workers": 1,
}
)
else:
config.update(
{
"workers": int(os.getenv("UVICORN_WORKERS", "5")),
}
)
return config
if __name__ == "__main__":
uvicorn.run("app.asgi:application", **build_config())