From 213dc97c178bf9f2e39796a7600d5182e22961b6 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 10 Jul 2025 08:48:42 -0600 Subject: [PATCH] Set ulimit (#19086) * Add script to set ulimits in case they are too low * Run the script * Set version * Set limit if it is too low --- Makefile | 2 +- .../rootfs/etc/s6-overlay/s6-rc.d/frigate/run | 1 + .../rootfs/usr/local/ulimit/set_ulimit.sh | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 docker/main/rootfs/usr/local/ulimit/set_ulimit.sh diff --git a/Makefile b/Makefile index b7c6ab821..80cbb519f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ default_target: local COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1) -VERSION = 0.15.0 +VERSION = 0.15.2 IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) BOARDS= #Initialized empty diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run index e4a1b20e5..a42afe300 100755 --- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run @@ -50,6 +50,7 @@ function set_libva_version() { echo "[INFO] Preparing Frigate..." migrate_db_path set_libva_version +/usr/local/ulimit/set_ulimit.sh echo "[INFO] Starting Frigate..." cd /opt/frigate || echo "[ERROR] Failed to change working directory to /opt/frigate" diff --git a/docker/main/rootfs/usr/local/ulimit/set_ulimit.sh b/docker/main/rootfs/usr/local/ulimit/set_ulimit.sh new file mode 100755 index 000000000..6c1bacfa2 --- /dev/null +++ b/docker/main/rootfs/usr/local/ulimit/set_ulimit.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Newer versions of containerd 2.X+ impose a very low soft file limit of 1024 +# This applies to OSs like HA OS (see https://github.com/home-assistant/operating-system/issues/4110) +# Attempt to increase this limit + +# Get current soft and hard nofile limits +current_soft_limit=$(ulimit -Sn) +current_hard_limit=$(ulimit -Hn) + +TARGET_SOFT_LIMIT=65536 +TARGET_HARD_LIMIT=65536 + +if [ "$current_soft_limit" -lt "$TARGET_SOFT_LIMIT" ]; then + # Attempt to set both soft and hard limits to the new value + # This requires sufficient privileges (e.g., running as root in the container) + if ulimit -n "$TARGET_SOFT_LIMIT:$TARGET_HARD_LIMIT"; then + new_soft_limit=$(ulimit -Sn) + new_hard_limit=$(ulimit -Hn) + + if [ "$new_soft_limit" -ne "$TARGET_SOFT_LIMIT" ] || [ "$new_hard_limit" -ne "$TARGET_HARD_LIMIT" ]; then + echo "Warning: Limits were set, but not to the exact target values. Check system constraints." + fi + else + echo "Error: Failed to set new nofile limits." + fi +fi \ No newline at end of file