Skip to content

Commit

Permalink
Correctly apply fix for high ulimit (SeleniumHQ#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain authored Apr 4, 2024
1 parent 74619b4 commit 9cbf328
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions NodeBase/start-novnc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions NodeBase/start-vnc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9cbf328

Please sign in to comment.