wire ProfileManager into app startup and FastAPI

- Create ProfileManager after dispatcher init
- Restore persisted profile on startup
- Pass dispatcher and profile_manager to FastAPI app
This commit is contained in:
Josh Hawkins 2026-03-05 12:56:53 -06:00
parent 76c65bbf6d
commit 26ec07985c
2 changed files with 21 additions and 0 deletions

View File

@ -69,6 +69,8 @@ def create_fastapi_app(
event_metadata_updater: EventMetadataPublisher,
config_publisher: CameraConfigUpdatePublisher,
replay_manager: DebugReplayManager,
dispatcher=None,
profile_manager=None,
enforce_default_admin: bool = True,
):
logger.info("Starting FastAPI app")
@ -151,6 +153,8 @@ def create_fastapi_app(
app.event_metadata_updater = event_metadata_updater
app.config_publisher = config_publisher
app.replay_manager = replay_manager
app.dispatcher = dispatcher
app.profile_manager = profile_manager
if frigate_config.auth.enabled:
secret = get_jwt_secret()

View File

@ -30,6 +30,7 @@ from frigate.comms.ws import WebSocketClient
from frigate.comms.zmq_proxy import ZmqProxy
from frigate.config.camera.updater import CameraConfigUpdatePublisher
from frigate.config.config import FrigateConfig
from frigate.config.profile_manager import ProfileManager
from frigate.const import (
CACHE_DIR,
CLIPS_DIR,
@ -349,6 +350,19 @@ class FrigateApp:
comms,
)
def init_profile_manager(self) -> None:
self.profile_manager = ProfileManager(
self.config, self.inter_config_updater
)
self.dispatcher.profile_manager = self.profile_manager
persisted = ProfileManager.load_persisted_profile()
if persisted and any(
persisted in cam.profiles for cam in self.config.cameras.values()
):
logger.info("Restoring persisted profile '%s'", persisted)
self.profile_manager.activate_profile(persisted)
def start_detectors(self) -> None:
for name in self.config.cameras.keys():
try:
@ -557,6 +571,7 @@ class FrigateApp:
self.init_inter_process_communicator()
self.start_detectors()
self.init_dispatcher()
self.init_profile_manager()
self.init_embeddings_client()
self.start_video_output_processor()
self.start_ptz_autotracker()
@ -586,6 +601,8 @@ class FrigateApp:
self.event_metadata_updater,
self.inter_config_updater,
self.replay_manager,
self.dispatcher,
self.profile_manager,
),
host="127.0.0.1",
port=5001,