mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-07 00:06:57 +01:00
allow db path to be customized
This commit is contained in:
parent
f20b1d75e6
commit
dd102ff01d
@ -184,6 +184,12 @@ logger:
|
|||||||
logs:
|
logs:
|
||||||
frigate.mqtt: error
|
frigate.mqtt: error
|
||||||
|
|
||||||
|
# Optional: database configuration
|
||||||
|
database:
|
||||||
|
# Optional: database path
|
||||||
|
# This may need to be in a custom location if network storage is used for clips
|
||||||
|
path: /media/frigate/clips/frigate.db
|
||||||
|
|
||||||
# Optional: detectors configuration
|
# Optional: detectors configuration
|
||||||
# USB Coral devices will be auto detected with CPU fallback
|
# USB Coral devices will be auto detected with CPU fallback
|
||||||
detectors:
|
detectors:
|
||||||
|
@ -103,7 +103,7 @@ class FrigateApp():
|
|||||||
self.detected_frames_queue = mp.Queue(maxsize=len(self.config.cameras.keys())*2)
|
self.detected_frames_queue = mp.Queue(maxsize=len(self.config.cameras.keys())*2)
|
||||||
|
|
||||||
def init_database(self):
|
def init_database(self):
|
||||||
self.db = SqliteExtDatabase(f"/{os.path.join(CLIPS_DIR, 'frigate.db')}")
|
self.db = SqliteExtDatabase(self.config.database.path)
|
||||||
models = [Event]
|
models = [Event]
|
||||||
self.db.bind(models)
|
self.db.bind(models)
|
||||||
self.db.create_tables(models, safe=True)
|
self.db.create_tables(models, safe=True)
|
||||||
|
@ -193,6 +193,9 @@ CAMERAS_SCHEMA = vol.Schema(vol.All(
|
|||||||
|
|
||||||
FRIGATE_CONFIG_SCHEMA = vol.Schema(
|
FRIGATE_CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
|
vol.Optional('database', default={}): {
|
||||||
|
vol.Optional('path', default=os.path.join(CLIPS_DIR, 'frigate.db')): str
|
||||||
|
},
|
||||||
vol.Optional('model', default={'width': 320, 'height': 320}): {
|
vol.Optional('model', default={'width': 320, 'height': 320}): {
|
||||||
vol.Required('width'): int,
|
vol.Required('width'): int,
|
||||||
vol.Required('height'): int
|
vol.Required('height'): int
|
||||||
@ -214,6 +217,19 @@ FRIGATE_CONFIG_SCHEMA = vol.Schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class DatabaseConfig():
|
||||||
|
def __init__(self, config):
|
||||||
|
self._path = config['path']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {
|
||||||
|
'path': self.path
|
||||||
|
}
|
||||||
|
|
||||||
class ModelConfig():
|
class ModelConfig():
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self._width = config['width']
|
self._width = config['width']
|
||||||
@ -781,6 +797,7 @@ class FrigateConfig():
|
|||||||
|
|
||||||
config = self._sub_env_vars(config)
|
config = self._sub_env_vars(config)
|
||||||
|
|
||||||
|
self._database = DatabaseConfig(config['database'])
|
||||||
self._model = ModelConfig(config['model'])
|
self._model = ModelConfig(config['model'])
|
||||||
self._detectors = { name: DetectorConfig(d) for name, d in config['detectors'].items() }
|
self._detectors = { name: DetectorConfig(d) for name, d in config['detectors'].items() }
|
||||||
self._mqtt = MqttConfig(config['mqtt'])
|
self._mqtt = MqttConfig(config['mqtt'])
|
||||||
@ -813,6 +830,7 @@ class FrigateConfig():
|
|||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
|
'database': self.database.to_dict(),
|
||||||
'model': self.model.to_dict(),
|
'model': self.model.to_dict(),
|
||||||
'detectors': {k: d.to_dict() for k, d in self.detectors.items()},
|
'detectors': {k: d.to_dict() for k, d in self.detectors.items()},
|
||||||
'mqtt': self.mqtt.to_dict(),
|
'mqtt': self.mqtt.to_dict(),
|
||||||
@ -821,6 +839,10 @@ class FrigateConfig():
|
|||||||
'logger': self.logger.to_dict()
|
'logger': self.logger.to_dict()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def database(self):
|
||||||
|
return self._database
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def model(self):
|
def model(self):
|
||||||
return self._model
|
return self._model
|
||||||
|
Loading…
Reference in New Issue
Block a user