mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 15:45:27 +03:00
Moved config initialization out of FrigateApp
This commit is contained in:
parent
28b701cb33
commit
5a9efccd2c
@ -85,10 +85,6 @@ class FrigateApp:
|
||||
self.region_grids: dict[str, list[list[dict[str, int]]]] = {}
|
||||
self.config = config
|
||||
|
||||
def set_environment_vars(self) -> None:
|
||||
for key, value in self.config.environment_vars.items():
|
||||
os.environ[key] = value
|
||||
|
||||
def ensure_dirs(self) -> None:
|
||||
for d in [
|
||||
CONFIG_DIR,
|
||||
@ -164,17 +160,6 @@ class FrigateApp:
|
||||
}
|
||||
self.ptz_metrics[camera_name]["ptz_motor_stopped"].set()
|
||||
|
||||
def set_log_levels(self) -> None:
|
||||
logging.getLogger().setLevel(self.config.logger.default.value.upper())
|
||||
for log, level in self.config.logger.logs.items():
|
||||
logging.getLogger(log).setLevel(level.value.upper())
|
||||
|
||||
if "werkzeug" not in self.config.logger.logs:
|
||||
logging.getLogger("werkzeug").setLevel("ERROR")
|
||||
|
||||
if "ws4py" not in self.config.logger.logs:
|
||||
logging.getLogger("ws4py").setLevel("ERROR")
|
||||
|
||||
def init_queues(self) -> None:
|
||||
# Queue for cameras to push tracked objects to
|
||||
self.detected_frames_queue: Queue = mp.Queue(
|
||||
@ -633,10 +618,12 @@ class FrigateApp:
|
||||
def start(self) -> None:
|
||||
logger.info(f"Starting Frigate ({VERSION})")
|
||||
|
||||
# Ensure global state.
|
||||
self.ensure_dirs()
|
||||
self.config.install()
|
||||
|
||||
# Start frigate services.
|
||||
self.init_camera_metrics()
|
||||
self.set_environment_vars()
|
||||
self.set_log_levels()
|
||||
self.init_queues()
|
||||
self.init_database()
|
||||
self.init_onvif()
|
||||
@ -648,7 +635,6 @@ class FrigateApp:
|
||||
self.check_db_data_migrations()
|
||||
self.init_inter_process_communicator()
|
||||
self.init_dispatcher()
|
||||
|
||||
self.start_detectors()
|
||||
self.start_video_output_processor()
|
||||
self.start_ptz_autotracker()
|
||||
|
||||
@ -1296,6 +1296,19 @@ class LoggerConfig(FrigateBaseModel):
|
||||
default_factory=dict, title="Log level for specified processes."
|
||||
)
|
||||
|
||||
def install(self):
|
||||
"""Install global logging state."""
|
||||
logging.getLogger().setLevel(self.default.value.upper())
|
||||
|
||||
log_levels = {
|
||||
"werkzeug": LogLevelEnum.error,
|
||||
"ws4py": LogLevelEnum.error,
|
||||
**self.logs,
|
||||
}
|
||||
|
||||
for log, level in log_levels.items():
|
||||
logging.getLogger(log).setLevel(level.value.upper())
|
||||
|
||||
|
||||
class CameraGroupConfig(FrigateBaseModel):
|
||||
"""Represents a group of cameras."""
|
||||
@ -1847,3 +1860,10 @@ class FrigateConfig(FrigateBaseModel):
|
||||
@classmethod
|
||||
def parse_object(cls, obj: Any, *, plus_api: Optional[PlusApi] = None):
|
||||
return cls.model_validate(obj, context={"plus_api": plus_api})
|
||||
|
||||
def install(self):
|
||||
"""Install global state from the config."""
|
||||
self.logger.install()
|
||||
|
||||
for key, value in self.environment_vars.items():
|
||||
os.environ[key] = value
|
||||
|
||||
Loading…
Reference in New Issue
Block a user