-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserve.py
More file actions
30 lines (24 loc) · 961 Bytes
/
Copy pathserve.py
File metadata and controls
30 lines (24 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import multiprocessing
import uvicorn
# Importa o objeto `app` diretamente (em vez da string "app.main:app") para que o
# PyInstaller consiga rastrear estaticamente toda a árvore de dependências quando
# o backend é empacotado no app desktop (Electron).
from app.config import settings
from app.main import app
def main() -> None:
# Lean runtime: single in-process server (uvicorn's default — no worker
# supervisor), no per-request access log, warnings only. The app is fully
# event-driven (it does no polling), so while idle it costs the host
# machine essentially nothing.
uvicorn.run(
app,
host=settings.server_host,
port=settings.server_port,
access_log=False,
log_level="warning",
)
if __name__ == "__main__":
# Necessário quando empacotado pelo PyInstaller (evita re-spawn do processo
# em plataformas que usam 'spawn').
multiprocessing.freeze_support()
main()