Skip to content

Commit

Permalink
nc-limits: added PHP threads and Redis mem limits
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Dec 5, 2017
1 parent 89f77e7 commit 3c85b80
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion etc/nextcloudpi-config.d/nc-limits.sh
Expand Up @@ -14,15 +14,38 @@
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#

DESCRIPTION="Configure system limits for NextCloudPi"
MAXFILESIZE_=2G
MEMORYLIMIT_=768M
PHPTHREADS_=0
REDISMEM_=3gb

DESCRIPTION="Configure system limits for NextCloudPi"
INFO="Set PHP threads to 0 in order to use all cores"

configure()
{
sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE_/" /var/www/nextcloud/.user.ini
sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" /var/www/nextcloud/.user.ini
sed -i "s/memory_limit=.*/memory_limit=$MEMORYLIMIT_/" /var/www/nextcloud/.user.ini

# adjust max PHP processes so Apps don't overload the board (#146)
[[ $PHPTHREADS_ -eq 0 ]] && PHPTHREADS_=$( nproc ) && echo "Using $PHPTHREADS_ PHP threads"
sed -i "s|pm.max_children =.*|pm.max_children = $PHPTHREADS_|" /etc/php/7.0/fpm/pool.d/www.conf
sed -i "s|pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS_|" /etc/php/7.0/fpm/pool.d/www.conf
sed -i "s|pm.start_servers =.*|pm.start_servers = $PHPTHREADS_|" /etc/php/7.0/fpm/pool.d/www.conf

# need to restart php
bash -c " sleep 3
systemctl stop php7.0-fpm
systemctl stop mysqld
sleep 0.5
systemctl start php7.0-fpm
systemctl start mysqld
" &>/dev/null &

# redis max memory
sed -i "s|maxmemory .*|maxmemory $REDISMEM_|" /etc/redis/redis.conf
systemctl restart redis
}

install() { :; }
Expand Down

0 comments on commit 3c85b80

Please sign in to comment.