Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some values #3666

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Containers/nextcloud/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
12 changes: 0 additions & 12 deletions Containers/nextcloud/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 11 additions & 13 deletions Containers/postgresql/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down