From 112c9ad58315486a7313f0d17b0a4555ce82b358 Mon Sep 17 00:00:00 2001 From: Simon L Date: Thu, 2 Nov 2023 20:19:55 +0100 Subject: [PATCH] fix some values Signed-off-by: Simon L --- Containers/nextcloud/Dockerfile | 8 ++++---- Containers/nextcloud/entrypoint.sh | 12 ------------ Containers/postgresql/start.sh | 24 +++++++++++------------- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index 599a8ff9d67..e8bfbd2ad98 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -195,10 +195,10 @@ RUN set -ex; \ \ grep -q '^pm = dynamic' /usr/local/etc/php-fpm.d/www.conf; \ sed -i 's/^pm = dynamic/pm = ondemand/' /usr/local/etc/php-fpm.d/www.conf; \ - sed -i 's/^pm.max_children =.*/pm.max_children = 80/' /usr/local/etc/php-fpm.d/www.conf; \ - sed -i 's/^pm.start_servers =.*/pm.start_servers = 2/' /usr/local/etc/php-fpm.d/www.conf; \ - sed -i 's/^pm.min_spare_servers =.*/pm.min_spare_servers = 1/' /usr/local/etc/php-fpm.d/www.conf; \ - sed -i 's/^pm.max_spare_servers =.*/pm.max_spare_servers = 3/' /usr/local/etc/php-fpm.d/www.conf; \ +# Sync this with max db connections +# We don't actually expect so many children but don't want to limit it artificially because people will report issues otherwise. +# Also children will usually be terminated again after the process is done due to the ondemand setting + sed -i 's/^pm.max_children =.*/pm.max_children = 5000/' /usr/local/etc/php-fpm.d/www.conf; \ sed -i 's|access.log = /proc/self/fd/2|access.log = /proc/self/fd/1|' /usr/local/etc/php-fpm.d/docker.conf; \ \ rm -rf /tmp/nextcloud-aio && \ diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 024ec1d3757..6fbb92833ba 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -30,18 +30,6 @@ redis.session.lock_retries = -1 redis.session.lock_wait_time = 10000 REDIS_CONF -echo "Setting php max children..." -MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo) -PHP_MAX_CHILDREN=$((MEMORY/50)) -# 100 is the default, we do not want to go lower than this -if [ "$PHP_MAX_CHILDREN" -lt 100 ]; then - PHP_MAX_CHILDREN=100 -fi -if [ -n "$PHP_MAX_CHILDREN" ]; then - sed -i "s/^pm.max_children =.*/pm.max_children = $PHP_MAX_CHILDREN/" /usr/local/etc/php-fpm.d/www.conf - sed -i "s/^;pm.process_idle_timeout =.*/pm.process_idle_timeout = 3s/" /usr/local/etc/php-fpm.d/www.conf -fi - # Check permissions in ncdata touch "$NEXTCLOUD_DATA_DIR/this-is-a-test-file" &>/dev/null if ! [ -f "$NEXTCLOUD_DATA_DIR/this-is-a-test-file" ]; then diff --git a/Containers/postgresql/start.sh b/Containers/postgresql/start.sh index af228efe9ea..33c851fd87d 100644 --- a/Containers/postgresql/start.sh +++ b/Containers/postgresql/start.sh @@ -148,24 +148,22 @@ fi # Modify postgresql.conf if [ -f "/var/lib/postgresql/data/postgresql.conf" ]; then - echo "Setting max connections..." - MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo) - MAX_CONNECTIONS=$((MEMORY/50+3)) - if [ -n "$MAX_CONNECTIONS" ]; then - # 100 is the default, we do not want to go lower than this - if [ "$MAX_CONNECTIONS" -lt 100 ]; then - MAX_CONNECTIONS=100 - fi - sed -i "s|^max_connections =.*|max_connections = $MAX_CONNECTIONS|" "/var/lib/postgresql/data/postgresql.conf" - fi + echo "Setting postgres values..." + + # 5000 connections is apparently the highest possible value with postgres so set it to that so that we don't run into a limit here. + # We don't actually expect so many connections but don't want to limit it artificially because people will report issues otherwise + # Also connections should usually be closed again after the process is done + # If we should actually exceed this limit, it is definitely a bug in Nextcloud server or some of its apps that does not close connections correctly and not a bug in AIO + sed -i "s|^max_connections =.*|max_connections = 5000|" "/var/lib/postgresql/data/postgresql.conf" # Do not log checkpoints if grep -q "#log_checkpoints" /var/lib/postgresql/data/postgresql.conf; then sed -i 's|#log_checkpoints.*|log_checkpoints = off|' /var/lib/postgresql/data/postgresql.conf fi - # Close idling connections automatically after 3s which does not seem to happen automatically so that we run into max_connections limits - if grep -q "#idle_session_timeout" /var/lib/postgresql/data/postgresql.conf; then - sed -i 's|#idle_session_timeout.*|idle_session_timeout = 3000|' /var/lib/postgresql/data/postgresql.conf + + # Closing idling connections automatically seems to break any logic so was reverted again to default where it is disabled + if grep -q "^idle_session_timeout" /var/lib/postgresql/data/postgresql.conf; then + sed -i 's|^idle_session_timeout.*|#idle_session_timeout|' /var/lib/postgresql/data/postgresql.conf fi fi