-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_dev.py
More file actions
28 lines (22 loc) · 926 Bytes
/
Copy pathrun_dev.py
File metadata and controls
28 lines (22 loc) · 926 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
"""Start the API with reload and a nodriver-friendly asyncio loop (Windows)."""
from __future__ import annotations
import os
import sys
import uvicorn
from core.nodriver_uvicorn_loop import UVICORN_WINDOWS_NODRIVER_LOOP
from core.win32_asyncio import ensure_proactor_event_loop
if __name__ == "__main__":
# Local Amazon worker follows API restarts (disable if Tauri alone manages workers).
os.environ.setdefault("GOUPIX_AUTO_START_AMAZON_WORKER", "1")
from migrations.run_migrations import main as run_migrations
run_migrations()
# Before uvicorn sets up the loop (otherwise main:app is not imported yet).
ensure_proactor_event_loop()
loop = UVICORN_WINDOWS_NODRIVER_LOOP if sys.platform == "win32" else "auto"
uvicorn.run(
"main:app",
host=os.environ.get("HOST", "0.0.0.0"),
port=int(os.environ.get("PORT", "8000")),
reload=True,
loop=loop,
)