mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-27 17:17:40 +03:00
move to services and add env var
This commit is contained in:
parent
0b131a2243
commit
fcaff15795
@ -2,7 +2,6 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import os
|
import os
|
||||||
import resource
|
|
||||||
import secrets
|
import secrets
|
||||||
import shutil
|
import shutil
|
||||||
from multiprocessing import Queue
|
from multiprocessing import Queue
|
||||||
@ -72,6 +71,7 @@ from frigate.timeline import TimelineProcessor
|
|||||||
from frigate.util.builtin import empty_and_close_queue
|
from frigate.util.builtin import empty_and_close_queue
|
||||||
from frigate.util.image import SharedMemoryFrameManager, UntrackedSharedMemory
|
from frigate.util.image import SharedMemoryFrameManager, UntrackedSharedMemory
|
||||||
from frigate.util.object import get_camera_regions_grid
|
from frigate.util.object import get_camera_regions_grid
|
||||||
|
from frigate.util.services import set_file_limit
|
||||||
from frigate.version import VERSION
|
from frigate.version import VERSION
|
||||||
from frigate.video import capture_camera, track_camera
|
from frigate.video import capture_camera, track_camera
|
||||||
from frigate.watchdog import FrigateWatchdog
|
from frigate.watchdog import FrigateWatchdog
|
||||||
@ -111,16 +111,6 @@ class FrigateApp:
|
|||||||
else:
|
else:
|
||||||
logger.debug(f"Skipping directory: {d}")
|
logger.debug(f"Skipping directory: {d}")
|
||||||
|
|
||||||
def set_file_limit(self, soft_limit: int) -> None:
|
|
||||||
current_soft, current_hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
|
||||||
logger.info(f"Current file limits - Soft: {current_soft}, Hard: {current_hard}")
|
|
||||||
|
|
||||||
new_soft = min(soft_limit, current_hard)
|
|
||||||
resource.setrlimit(resource.RLIMIT_NOFILE, (new_soft, current_hard))
|
|
||||||
logger.info(
|
|
||||||
f"File limit set. New soft limit: {new_soft}, Hard limit remains: {current_hard}"
|
|
||||||
)
|
|
||||||
|
|
||||||
def init_camera_metrics(self) -> None:
|
def init_camera_metrics(self) -> None:
|
||||||
# create camera_metrics
|
# create camera_metrics
|
||||||
for camera_name in self.config.cameras.keys():
|
for camera_name in self.config.cameras.keys():
|
||||||
@ -599,7 +589,7 @@ class FrigateApp:
|
|||||||
self.ensure_dirs()
|
self.ensure_dirs()
|
||||||
|
|
||||||
# Set soft file limits.
|
# Set soft file limits.
|
||||||
self.set_file_limit(65536)
|
set_file_limit()
|
||||||
|
|
||||||
# Start frigate services.
|
# Start frigate services.
|
||||||
self.init_camera_metrics()
|
self.init_camera_metrics()
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import resource
|
||||||
import signal
|
import signal
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import traceback
|
import traceback
|
||||||
@ -632,3 +633,16 @@ async def get_video_properties(
|
|||||||
result["fourcc"] = fourcc
|
result["fourcc"] = fourcc
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def set_file_limit() -> None:
|
||||||
|
soft_limit = int(os.getenv("SOFT_FILE_LIMIT", "65536") or "65536")
|
||||||
|
|
||||||
|
current_soft, current_hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||||
|
logger.info(f"Current file limits - Soft: {current_soft}, Hard: {current_hard}")
|
||||||
|
|
||||||
|
new_soft = min(soft_limit, current_hard)
|
||||||
|
resource.setrlimit(resource.RLIMIT_NOFILE, (new_soft, current_hard))
|
||||||
|
logger.info(
|
||||||
|
f"File limit set. New soft limit: {new_soft}, Hard limit remains: {current_hard}"
|
||||||
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user