feat: dynamically set shm
Set a higher SHM if there's 4GB+ of RAM on the host. Attempting to fix DRIVER_ERROR encountered in the wild.
This commit is contained in:
parent
7f1e11f86d
commit
4a24932922
|
@ -112,7 +112,7 @@ services:
|
||||||
# and the store-message-db-url is set to use Postgres
|
# and the store-message-db-url is set to use Postgres
|
||||||
image: postgres:15.4-alpine3.18
|
image: postgres:15.4-alpine3.18
|
||||||
restart: on-failure:5
|
restart: on-failure:5
|
||||||
shm_size: '1g' # Set shared memory size to 1 GB
|
shm_size: "${POSTGRES_SHM:-1g}" # Set default shared memory size to 1 GB
|
||||||
environment:
|
environment:
|
||||||
<<: *pg_env
|
<<: *pg_env
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -54,10 +54,24 @@ fi
|
||||||
# check if STORAGE_SIZE is already specified
|
# check if STORAGE_SIZE is already specified
|
||||||
if [ -f "./.env" ]; then
|
if [ -f "./.env" ]; then
|
||||||
. ./.env
|
. ./.env
|
||||||
if [ -n "$STORAGE_SIZE" ]; then
|
fi
|
||||||
>&2 echo "STORAGE_SIZE is specified in .env file, doing nothing"
|
|
||||||
exit 0
|
# Set PostgreSQL container Shared Memory value
|
||||||
|
if [ -z "${POSTGRES_SHM}" ]; then
|
||||||
|
TOTAL_MEM_MB=$(free -m|grep Mem| awk '{ print $2 }')
|
||||||
|
if [ "${TOTAL_MEM_MB}" -ge 4096 ]; then
|
||||||
|
# Allocate 2GB of Shared Memory for Postgres if machine has more than 4GB RAM
|
||||||
|
POSTGRES_SHM='2g'
|
||||||
|
echo "Setting PostgreSQL container SHM to ${POSTGRES_SHM}"
|
||||||
|
echo "POSTGRES_SHM=${POSTGRES_SHM}" >> .env
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
>&2 echo "POSTGRES_SHM is already specified in .env file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$STORAGE_SIZE" ]; then
|
||||||
|
>&2 echo "STORAGE_SIZE is specified in .env file, doing nothing"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SUDO=""
|
SUDO=""
|
||||||
|
|
Loading…
Reference in New Issue