Skip to content

Commit

Permalink
redis: change eviction policy
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Sep 30, 2018
1 parent 6b14527 commit 4f20b71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
14 changes: 7 additions & 7 deletions etc/ncp-config.d/nc-limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ configure()
local CONF=/var/www/nextcloud/.user.ini
local CURRENT_PHP_MEM="$( grep "^memory_limit" "$CONF" | sed 's|.*=||' )"
[[ "$MEMORYLIMIT_" == "0" ]] && MEMORYLIMIT_=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP"
sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE_/" "$CONF"
sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" "$CONF"
sed -i "s/memory_limit=.*/memory_limit=$MEMORYLIMIT_/" "$CONF"
sed -i "s/^post_max_size=.*/post_max_size=$MAXFILESIZE_/" "$CONF"
sed -i "s/^upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" "$CONF"
sed -i "s/^memory_limit=.*/memory_limit=$MEMORYLIMIT_/" "$CONF"

# MAX PHP THREADS
local CONF=/etc/php/${PHPVER}/fpm/pool.d/www.conf
local CURRENT_THREADS=$( grep "^pm.max_children" "$CONF" | awk '{ print $3 }' )
[[ "$PHPTHREADS_" == "0" ]] && PHPTHREADS_=$( nproc ) && echo "Using $PHPTHREADS_ PHP threads"
sed -i "s|pm.max_children =.*|pm.max_children = $PHPTHREADS_|" "$CONF"
sed -i "s|pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS_|" "$CONF"
sed -i "s|pm.start_servers =.*|pm.start_servers = $PHPTHREADS_|" "$CONF"
sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS_|" "$CONF"
sed -i "s|^pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS_|" "$CONF"
sed -i "s|^pm.start_servers =.*|pm.start_servers = $PHPTHREADS_|" "$CONF"

# RESTART PHP
[[ "$PHPTHREADS_" != "$CURRENT_THREADS" ]] || \
Expand All @@ -62,7 +62,7 @@ configure()
local CURRENT_REDIS_MEM=$( grep "^maxmemory" "$CONF" | awk '{ print $2 }' )
[[ "$REDISMEM_" == "0" ]] && REDISMEM_=$AUTOMEM && echo "Using ${AUTOMEM}B for Redis"
[[ "$REDISMEM_" != "$CURRENT_REDIS_MEM" ]] && {
sed -i "s|maxmemory .*|maxmemory $REDISMEM_|" "$CONF"
sed -i "s|^maxmemory .*|maxmemory $REDISMEM_|" "$CONF"
service redis-server restart
}
}
Expand Down
1 change: 1 addition & 0 deletions etc/ncp-config.d/nc-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ install()
sed -i "s|# unixsocket .*|unixsocket /var/run/redis/redis.sock|" $REDIS_CONF
sed -i "s|# unixsocketperm .*|unixsocketperm 770|" $REDIS_CONF
sed -i "s|# requirepass .*|requirepass $REDISPASS|" $REDIS_CONF
sed -i 's|# maxmemory-policy .*|maxmemory-policy allkeys-lru|' $REDIS_CONF
sed -i 's|# rename-command CONFIG ""|rename-command CONFIG ""|' $REDIS_CONF
sed -i "s|^port.*|port 0|" $REDIS_CONF
echo "maxmemory $REDIS_MEM" >> $REDIS_CONF
Expand Down
8 changes: 8 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ EOF
service php${PHPVER}-fpm start
service mysql start
" &>/dev/null &

# PHP7.2 end

# Redis eviction policy
grep -q "^maxmemory-policy allkeys-lru" /etc/redis/redis.conf || {
sed -i 's|# maxmemory-policy .*|maxmemory-policy allkeys-lru|' /etc/redis/redis.conf
service redis-server restart
}
}

} # end - only live updates
Expand Down

0 comments on commit 4f20b71

Please sign in to comment.