Skip to content

Commit 9cbf328

Browse files
authored
Correctly apply fix for high ulimit (#2192)
1 parent 74619b4 commit 9cbf328

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

NodeBase/start-novnc.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then
77
if [ "${START_NO_VNC:-$SE_START_NO_VNC}" = true ] ; then
88

99
# Guard against unreasonably high nofile limits. See https://github.com/SeleniumHQ/docker-selenium/issues/2045
10-
ULIMIT=${SE_VNC_ULIMIT:-100000}
11-
if [[ ${ULIMIT} -ge 100000 ]]; then
12-
echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${ULIMIT}."
13-
ulimit -Sv ${ULIMIT}
10+
# Try to set a new limit if the current limit is too high, or the user explicitly specified a custom limit
11+
TOO_HIGH_ULIMIT=100000
12+
if [[ $(ulimit -n) -gt $TOO_HIGH_ULIMIT || ! -z "${SE_VNC_ULIMIT}" ]]; then
13+
NEW_ULIMIT=${SE_VNC_ULIMIT:-${TOO_HIGH_ULIMIT}}
14+
echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${NEW_ULIMIT}."
15+
ulimit -n ${NEW_ULIMIT}
1416
if [ $? -eq 0 ]; then
15-
echo "Successfully update the open file descriptor limit."
17+
echo "Successfully updated the open file descriptor limit."
1618
else
1719
echo "The open file descriptor limit could not be updated."
1820
fi

NodeBase/start-vnc.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then
4545
done
4646

4747
# Guard against unreasonably high nofile limits. See https://github.com/SeleniumHQ/docker-selenium/issues/2045
48-
ULIMIT=${SE_VNC_ULIMIT:-100000}
49-
if [[ ${ULIMIT} -ge 100000 ]]; then
50-
echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${ULIMIT}."
51-
ulimit -Sv ${ULIMIT}
48+
# Try to set a new limit if the current limit is too high, or the user explicitly specified a custom limit
49+
TOO_HIGH_ULIMIT=100000
50+
if [[ $(ulimit -n) -gt $TOO_HIGH_ULIMIT || ! -z "${SE_VNC_ULIMIT}" ]]; then
51+
NEW_ULIMIT=${SE_VNC_ULIMIT:-${TOO_HIGH_ULIMIT}}
52+
echo "Trying to update the open file descriptor limit from $(ulimit -n) to ${NEW_ULIMIT}."
53+
ulimit -n ${NEW_ULIMIT}
5254
if [ $? -eq 0 ]; then
53-
echo "Successfully update the open file descriptor limit."
55+
echo "Successfully updated the open file descriptor limit."
5456
else
5557
echo "The open file descriptor limit could not be updated."
5658
fi

0 commit comments

Comments
 (0)