From 9cbf32822202c3c5cdc86c0eb47747ce3329bdc8 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 4 Apr 2024 21:52:17 +0200 Subject: [PATCH] Correctly apply fix for high ulimit (#2192) --- NodeBase/start-novnc.sh | 12 +++++++----- NodeBase/start-vnc.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/NodeBase/start-novnc.sh b/NodeBase/start-novnc.sh index c3cb4efa6..4fc8d9e48 100755 --- a/NodeBase/start-novnc.sh +++ b/NodeBase/start-novnc.sh @@ -7,12 +7,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then if [ "${START_NO_VNC:-$SE_START_NO_VNC}" = true ] ; then # Guard against unreasonably high nofile limits. See https://github.com/SeleniumHQ/docker-selenium/issues/2045 - ULIMIT=${SE_VNC_ULIMIT:-100000} - if [[ ${ULIMIT} -ge 100000 ]]; then - echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${ULIMIT}." - ulimit -Sv ${ULIMIT} + # Try to set a new limit if the current limit is too high, or the user explicitly specified a custom limit + TOO_HIGH_ULIMIT=100000 + if [[ $(ulimit -n) -gt $TOO_HIGH_ULIMIT || ! -z "${SE_VNC_ULIMIT}" ]]; then + NEW_ULIMIT=${SE_VNC_ULIMIT:-${TOO_HIGH_ULIMIT}} + echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${NEW_ULIMIT}." + ulimit -n ${NEW_ULIMIT} if [ $? -eq 0 ]; then - echo "Successfully update the open file descriptor limit." + echo "Successfully updated the open file descriptor limit." else echo "The open file descriptor limit could not be updated." fi diff --git a/NodeBase/start-vnc.sh b/NodeBase/start-vnc.sh index c4419b0a1..ae96bd38f 100755 --- a/NodeBase/start-vnc.sh +++ b/NodeBase/start-vnc.sh @@ -45,12 +45,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then done # Guard against unreasonably high nofile limits. See https://github.com/SeleniumHQ/docker-selenium/issues/2045 - ULIMIT=${SE_VNC_ULIMIT:-100000} - if [[ ${ULIMIT} -ge 100000 ]]; then - echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${ULIMIT}." - ulimit -Sv ${ULIMIT} + # Try to set a new limit if the current limit is too high, or the user explicitly specified a custom limit + TOO_HIGH_ULIMIT=100000 + if [[ $(ulimit -n) -gt $TOO_HIGH_ULIMIT || ! -z "${SE_VNC_ULIMIT}" ]]; then + NEW_ULIMIT=${SE_VNC_ULIMIT:-${TOO_HIGH_ULIMIT}} + echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${NEW_ULIMIT}." + ulimit -n ${NEW_ULIMIT} if [ $? -eq 0 ]; then - echo "Successfully update the open file descriptor limit." + echo "Successfully updated the open file descriptor limit." else echo "The open file descriptor limit could not be updated." fi