mirror of
https://github.com/we-promise/sure.git
synced 2026-05-25 05:24:57 +00:00
* feat(docker): add jemalloc to reduce memory fragmentation Install libjemalloc2 in the base image and preload it via LD_PRELOAD in docker-entrypoint when available. Reduces RSS growth from glibc's default allocator fragmentation under Rails workloads. * feat(docker): add DISABLE_JEMALLOC env var + preserve existing LD_PRELOAD * feat(docker): add jemalloc status logging to entrypoint * refactor(docker): simplify jemalloc logging to warn-only when disabled/missing
19 lines
599 B
Bash
Executable File
19 lines
599 B
Bash
Executable File
#!/bin/bash -e
|
|
|
|
# Use jemalloc to reduce memory fragmentation if available
|
|
JEMALLOC="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2"
|
|
if [ -f "$JEMALLOC" ] && [ -z "${DISABLE_JEMALLOC}" ]; then
|
|
export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$JEMALLOC"
|
|
else
|
|
[ -n "${DISABLE_JEMALLOC}" ] \
|
|
&& echo "WARNING: jemalloc disabled via DISABLE_JEMALLOC" \
|
|
|| echo "WARNING: jemalloc not found at $JEMALLOC, skipping"
|
|
fi
|
|
|
|
# If running the rails server then create or migrate existing database
|
|
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
|
|
./bin/rails db:prepare
|
|
fi
|
|
|
|
exec "${@}"
|