Dockerfile, startup script: add rabbitmq ulimit

This change works around an issue in the rabbitmq-server version shipped
with Ubuntu 20.04. Large emptyfiles limits in docker
containers which run on hosts with low emptyfiles limits cause rabbitmq
to break. It will use use 100% CPU of a single core when started, then
time out (i.e. fail to start). An erlang process 'erl_child_setup'
will continue to use 100% CPU even after rabbitmq failed to
start (see https://github.com/docker-library/rabbitmq/issues/545).

The change adds a default emptyfiles limit to rabbitmq-server via
/etc/default/rabbitmq-server, which is created in the Dockerfile before
rabbitmq is installed. The default is generous: 65536.

Additionally, the change ads a new container environment variable
RABBITMQ_EMPTYFILES_LIMIT which, when set, will override the default
above.
This commit is contained in:
Thilo Fromm 2022-09-12 09:56:21 +02:00
parent 558353ee99
commit f25453a178
2 changed files with 15 additions and 1 deletions

View file

@ -5,6 +5,10 @@ ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=nonint
ARG ONLYOFFICE_VALUE=onlyoffice
RUN echo "# Enforce emptyfiles ulimit for rabbitmq to work around https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/491" \
| tee -a /etc/default/rabbitmq-server && \
echo "ulimit -n 65536" | tee -a /etc/default/rabbitmq-server
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
apt-get -y update && \
apt-get -yq install wget apt-transport-https gnupg locales && \
@ -13,7 +17,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
chmod 644 /etc/apt/trusted.gpg.d/onlyoffice.gpg && \
locale-gen en_US.UTF-8 && \
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections && \
apt-get -yq install \
apt-get -yq -o Dpkg::Options::="--force-confold" install \
adduser \
apt-utils \
bomstrip \

View file

@ -553,6 +553,16 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
LOCAL_SERVICES+=("rabbitmq-server")
# allow Rabbitmq startup after container kill
rm -rf /var/run/rabbitmq
# Apply user-defined emptyfiles limit if set.
# See https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/491.
if [ -n "${RABBITMQ_EMPTYFILES_LIMIT:-}" ]; then
echo "Applying custom emptyfiles limit"
{
head -n -1 /etc/default/rabbitmq-server
echo "ulimit -n ${RABBITMQ_EMPTYFILES_LIMIT}"
} | tee /etc/default/rabbitmq-server
fi
fi
if [ ${REDIS_ENABLED} = "true" ]; then