Skip to content

Commit

Permalink
Dockerfile, startup script: add rabbitmq ulimit
Browse files Browse the repository at this point in the history
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 docker-library/rabbitmq#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.
  • Loading branch information
t-lo committed Sep 12, 2022
1 parent 558353e commit f25453a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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 \
Expand Down
10 changes: 10 additions & 0 deletions run-document-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f25453a

Please sign in to comment.