thay doi tinh nang chay trong mang noi bo

This commit is contained in:
2026-04-27 22:05:18 +07:00
parent a89e145497
commit 0de7d67511
8 changed files with 146 additions and 41 deletions
+2 -2
View File
@@ -69,8 +69,8 @@ async def _scheduler_loop() -> None:
async def _startup() -> None:
cfg = await store.load()
recordings_dir = cfg.recordings_dir
if Path(recordings_dir).exists():
app.mount("/videos", StaticFiles(directory=recordings_dir), name="videos")
Path(recordings_dir).mkdir(parents=True, exist_ok=True)
app.mount("/videos", StaticFiles(directory=recordings_dir), name="videos")
asyncio.create_task(_scheduler_loop())
+9 -3
View File
@@ -1,3 +1,5 @@
import os
from pydantic import BaseModel, Field
@@ -14,9 +16,13 @@ class Schedule(BaseModel):
class AppConfig(BaseModel):
mediamtx_api_url: str = "http://127.0.0.1:9997"
mediamtx_webrtc_url: str = "http://127.0.0.1:8889"
recordings_dir: str = "/recordings"
mediamtx_api_url: str = Field(
default_factory=lambda: os.getenv("MEDIAMTX_API_URL", "http://127.0.0.1:9997")
)
mediamtx_webrtc_url: str = Field(
default_factory=lambda: os.getenv("MEDIAMTX_WEBRTC_URL", "http://127.0.0.1:8889")
)
recordings_dir: str = Field(default_factory=lambda: os.getenv("RECORDINGS_DIR", "/recordings"))
cameras: list[Camera] = Field(default_factory=list)
schedule: Schedule = Field(default_factory=Schedule)