Ensure nginx worker processes respects docker limits

This commit is contained in:
Felipe Santos 2024-06-05 15:02:06 -03:00
parent 8c96dfe1d1
commit 0a92f4fc46
2 changed files with 6 additions and 2 deletions

View File

@ -30,6 +30,9 @@ RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \
--mount=type=cache,target=/root/.ccache \ --mount=type=cache,target=/root/.ccache \
/deps/build_nginx.sh /deps/build_nginx.sh
# https://github.com/felipecrs/cgroup-scripts/commits/master/get_cpus.sh
ADD --link --chmod=755 "https://github.com/felipecrs/cgroup-scripts/raw/178c3ed0cb55465af6652fbd2b419573ccadea8a/get_cpus.sh" /usr/local/nginx/
FROM scratch AS go2rtc FROM scratch AS go2rtc
ARG TARGETARCH ARG TARGETARCH
WORKDIR /rootfs/usr/local/go2rtc/bin WORKDIR /rootfs/usr/local/go2rtc/bin

View File

@ -12,8 +12,9 @@ function set_worker_processes() {
# Capture number of assigned CPUs to calculate worker processes # Capture number of assigned CPUs to calculate worker processes
local proc_count local proc_count
if proc_count=$(nproc --all) && [[ $proc_count -gt 4 ]]; then proc_count=$(/usr/local/nginx/get_cpus.sh)
proc_count=4; if [[ "$proc_count" -gt 4 ]]; then
proc_count=4
fi fi
# we need to catch any errors because sed will fail if user has bind mounted a custom nginx file # we need to catch any errors because sed will fail if user has bind mounted a custom nginx file