mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
enable mounting tmpfs volume on start
This commit is contained in:
parent
5b5159f4dd
commit
247e2677f3
@ -242,6 +242,10 @@ save_clips:
|
||||
# NOTE: If an object is being tracked for longer than this amount of time, the cache
|
||||
# will begin to expire and the resulting clip will be the last x seconds of the event.
|
||||
max_seconds: 300
|
||||
# Optional: size of tmpfs mount to create for cache files (default: not set)
|
||||
# mount -t tmpfs -o size={tmpfs_cache_size} tmpfs /tmp/cache
|
||||
# Notice: If you have mounted a tmpfs volume through docker, this value should not be set in your config
|
||||
tmpfs_cache_size: 256m
|
||||
# Optional: Retention settings for clips (default: shown below)
|
||||
retain:
|
||||
# Required: Default retention days (default: shown below)
|
||||
|
@ -38,6 +38,13 @@ class FrigateApp():
|
||||
self.camera_metrics = {}
|
||||
|
||||
def ensure_dirs(self):
|
||||
tmpfs_size = self.config.save_clips.tmpfs_cache_size
|
||||
if tmpfs_size:
|
||||
logger.info(f"Creating tmpfs of size {tmpfs_size}")
|
||||
rc = os.system(f"mount -t tmpfs -o size={tmpfs_size} tmpfs /tmp/cache")
|
||||
if rc != 0:
|
||||
logger.error(f"Failed to create tmpfs, error code: {rc}")
|
||||
|
||||
for d in [RECORD_DIR, CLIPS_DIR, CACHE_DIR]:
|
||||
if not os.path.exists(d) and not os.path.islink(d):
|
||||
logger.info(f"Creating directory: {d}")
|
||||
@ -173,19 +180,20 @@ class FrigateApp():
|
||||
def start(self):
|
||||
self.init_logger()
|
||||
try:
|
||||
self.ensure_dirs()
|
||||
try:
|
||||
self.init_config()
|
||||
except Exception as e:
|
||||
logger.error(f"Error parsing config: {e}")
|
||||
self.log_process.terminate()
|
||||
sys.exit(1)
|
||||
self.ensure_dirs()
|
||||
self.check_config()
|
||||
self.set_log_levels()
|
||||
self.init_queues()
|
||||
self.init_database()
|
||||
self.init_mqtt()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.error(e)
|
||||
self.log_process.terminate()
|
||||
sys.exit(1)
|
||||
|
@ -51,6 +51,7 @@ SAVE_CLIPS_RETAIN_SCHEMA = vol.Schema(
|
||||
SAVE_CLIPS_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional('max_seconds', default=300): int,
|
||||
'tmpfs_cache_size': str,
|
||||
vol.Optional('retain', default={}): SAVE_CLIPS_RETAIN_SCHEMA
|
||||
}
|
||||
)
|
||||
@ -410,11 +411,16 @@ class SaveClipsRetainConfig():
|
||||
class SaveClipsConfig():
|
||||
def __init__(self, config):
|
||||
self._max_seconds = config['max_seconds']
|
||||
self._tmpfs_cache_size = config.get('tmpfs_cache_size', '').strip()
|
||||
self._retain = SaveClipsRetainConfig(config['retain'], config['retain'])
|
||||
|
||||
@property
|
||||
def max_seconds(self):
|
||||
return self._max_seconds
|
||||
|
||||
@property
|
||||
def tmpfs_cache_size(self):
|
||||
return self._tmpfs_cache_size
|
||||
|
||||
@property
|
||||
def retain(self):
|
||||
@ -423,6 +429,7 @@ class SaveClipsConfig():
|
||||
def to_dict(self):
|
||||
return {
|
||||
'max_seconds': self.max_seconds,
|
||||
'tmpfs_cache_size': self.tmpfs_cache_size,
|
||||
'retain': self.retain.to_dict()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user