File tree Expand file tree Collapse file tree 4 files changed +21
-58
lines changed
etc/s6-overlay/s6-rc.d/frigate Expand file tree Collapse file tree 4 files changed +21
-58
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ function set_libva_version() {
5050echo "[INFO] Preparing Frigate..."
5151migrate_db_path
5252set_libva_version
53- /usr/local/ulimit/set_ulimit.sh
5453echo "[INFO] Starting Frigate..."
5554
5655cd /opt/frigate || echo "[ERROR] Failed to change working directory to /opt/frigate"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 7171from frigate .util .builtin import empty_and_close_queue
7272from frigate .util .image import SharedMemoryFrameManager , UntrackedSharedMemory
7373from frigate .util .object import get_camera_regions_grid
74+ from frigate .util .services import set_file_limit
7475from frigate .version import VERSION
7576from frigate .video import capture_camera , track_camera
7677from frigate .watchdog import FrigateWatchdog
@@ -587,6 +588,9 @@ def start(self) -> None:
587588 # Ensure global state.
588589 self .ensure_dirs ()
589590
591+ # Set soft file limits.
592+ set_file_limit ()
593+
590594 # Start frigate services.
591595 self .init_camera_metrics ()
592596 self .init_queues ()
Original file line number Diff line number Diff line change 55import logging
66import os
77import re
8+ import resource
89import signal
910import subprocess as sp
1011import traceback
@@ -632,3 +633,19 @@ async def calculate_duration(video: Optional[any]) -> float:
632633 result ["fourcc" ] = fourcc
633634
634635 return result
636+
637+
638+ def set_file_limit () -> None :
639+ # Newer versions of containerd 2.X+ impose a very low soft file limit of 1024
640+ # This applies to OSs like HA OS (see https://github.com/home-assistant/operating-system/issues/4110)
641+ # Attempt to increase this limit
642+ soft_limit = int (os .getenv ("SOFT_FILE_LIMIT" , "65536" ) or "65536" )
643+
644+ current_soft , current_hard = resource .getrlimit (resource .RLIMIT_NOFILE )
645+ logger .info (f"Current file limits - Soft: { current_soft } , Hard: { current_hard } " )
646+
647+ new_soft = min (soft_limit , current_hard )
648+ resource .setrlimit (resource .RLIMIT_NOFILE , (new_soft , current_hard ))
649+ logger .info (
650+ f"File limit set. New soft limit: { new_soft } , Hard limit remains: { current_hard } "
651+ )
You can’t perform that action at this time.
0 commit comments