mirror of
https://github.com/logos-messaging/logos-messaging-nim-compose.git
synced 2026-01-04 15:03:06 +00:00
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
32b3b917c7
commit
0b434ce789
@ -111,7 +111,7 @@ services:
|
||||
# and the store-message-db-url is set to use Postgres
|
||||
image: postgres:15.4-alpine3.18
|
||||
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:
|
||||
<<: *pg_env
|
||||
volumes:
|
||||
|
||||
@ -54,10 +54,24 @@ fi
|
||||
# check if STORAGE_SIZE is already specified
|
||||
if [ -f "./.env" ]; then
|
||||
. ./.env
|
||||
if [ -n "$STORAGE_SIZE" ]; then
|
||||
>&2 echo "STORAGE_SIZE is specified in .env file, doing nothing"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
SUDO=""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user