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
96a44eb7bf
commit
03f3ba8008
@ -242,6 +242,10 @@ save_clips:
|
|||||||
# NOTE: If an object is being tracked for longer than this amount of time, the cache
|
# 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.
|
# will begin to expire and the resulting clip will be the last x seconds of the event.
|
||||||
max_seconds: 300
|
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)
|
# Optional: Retention settings for clips (default: shown below)
|
||||||
retain:
|
retain:
|
||||||
# Required: Default retention days (default: shown below)
|
# Required: Default retention days (default: shown below)
|
||||||
|
@ -38,6 +38,13 @@ class FrigateApp():
|
|||||||
self.camera_metrics = {}
|
self.camera_metrics = {}
|
||||||
|
|
||||||
def ensure_dirs(self):
|
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]:
|
for d in [RECORD_DIR, CLIPS_DIR, CACHE_DIR]:
|
||||||
if not os.path.exists(d) and not os.path.islink(d):
|
if not os.path.exists(d) and not os.path.islink(d):
|
||||||
logger.info(f"Creating directory: {d}")
|
logger.info(f"Creating directory: {d}")
|
||||||
@ -173,19 +180,20 @@ class FrigateApp():
|
|||||||
def start(self):
|
def start(self):
|
||||||
self.init_logger()
|
self.init_logger()
|
||||||
try:
|
try:
|
||||||
self.ensure_dirs()
|
|
||||||
try:
|
try:
|
||||||
self.init_config()
|
self.init_config()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error parsing config: {e}")
|
logger.error(f"Error parsing config: {e}")
|
||||||
self.log_process.terminate()
|
self.log_process.terminate()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
self.ensure_dirs()
|
||||||
self.check_config()
|
self.check_config()
|
||||||
self.set_log_levels()
|
self.set_log_levels()
|
||||||
self.init_queues()
|
self.init_queues()
|
||||||
self.init_database()
|
self.init_database()
|
||||||
self.init_mqtt()
|
self.init_mqtt()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
self.log_process.terminate()
|
self.log_process.terminate()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -51,6 +51,7 @@ SAVE_CLIPS_RETAIN_SCHEMA = vol.Schema(
|
|||||||
SAVE_CLIPS_SCHEMA = vol.Schema(
|
SAVE_CLIPS_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional('max_seconds', default=300): int,
|
vol.Optional('max_seconds', default=300): int,
|
||||||
|
'tmpfs_cache_size': str,
|
||||||
vol.Optional('retain', default={}): SAVE_CLIPS_RETAIN_SCHEMA
|
vol.Optional('retain', default={}): SAVE_CLIPS_RETAIN_SCHEMA
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -410,12 +411,17 @@ class SaveClipsRetainConfig():
|
|||||||
class SaveClipsConfig():
|
class SaveClipsConfig():
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self._max_seconds = config['max_seconds']
|
self._max_seconds = config['max_seconds']
|
||||||
|
self._tmpfs_cache_size = config.get('tmpfs_cache_size', '').strip()
|
||||||
self._retain = SaveClipsRetainConfig(config['retain'], config['retain'])
|
self._retain = SaveClipsRetainConfig(config['retain'], config['retain'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_seconds(self):
|
def max_seconds(self):
|
||||||
return self._max_seconds
|
return self._max_seconds
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tmpfs_cache_size(self):
|
||||||
|
return self._tmpfs_cache_size
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def retain(self):
|
def retain(self):
|
||||||
return self._retain
|
return self._retain
|
||||||
@ -423,6 +429,7 @@ class SaveClipsConfig():
|
|||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
'max_seconds': self.max_seconds,
|
'max_seconds': self.max_seconds,
|
||||||
|
'tmpfs_cache_size': self.tmpfs_cache_size,
|
||||||
'retain': self.retain.to_dict()
|
'retain': self.retain.to_dict()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user