Skip to content

Commit 4d12686

Browse files
committed
Add "vm_memory_high_watermark" to the generated config, sourced from the value of the "memory.limit_in_bytes" cgroup restriction
1 parent eb621e2 commit 4d12686

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docker-entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ if [ "$1" = 'rabbitmq-server' ] && [ "$haveConfig" ]; then
212212
"{ loopback_users, $(rabbit_array) }"
213213
)
214214

215+
# https://github.com/rabbitmq/rabbitmq-website/pull/96/files
216+
# "If the absolute limit is larger than the installed RAM or available virtual address space, the threshold is set to whichever limit is smaller."
217+
# specifically, if a memory limit isn't supplied to the container and "memory.limit_in_bytes" is thus an enormous constant, RabbitMQ will ignore it and use maximum available memory or address space instead
218+
if [ -r /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
219+
memLimit="$(< /sys/fs/cgroup/memory/memory.limit_in_bytes)"
220+
rabbitConfig+=( "{ vm_memory_high_watermark, { absolute, $(( memLimit / 1024 / 1024 )) } }" )
221+
fi
222+
215223
if [ "$haveSslConfig" ]; then
216224
IFS=$'\n'
217225
rabbitSslOptions=( $(rabbit_env_config 'ssl' "${sslConfigKeys[@]}") )

0 commit comments

Comments
 (0)