Skip to content

Commit

Permalink
nc-limits: autocalculate database memory
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Mar 5, 2019
1 parent 54565e4 commit bf1fc1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 12 additions & 3 deletions bin/ncp/CONFIG/nc-limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ configure()
[[ $PHPTHREADS -eq 0 ]] && PHPTHREADS=$( nproc )
[[ $PHPTHREADS -lt 3 ]] && PHPTHREADS=3
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 =.*|pm = static|" "$CONF"
sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS|" "$CONF"

# DATABASE MEMORY
AUTOMEM=$(( TOTAL_MEM * 40 / 100 ))
local CONF=/etc/mysql/mariadb.conf.d/91-ncp.cnf
local CURRENT_DB_MEM=$(grep "^innodb_buffer_pool_size" "$CONF" | awk '{ print $3 }')
echo "Using $AUTOMEM memory for the database"
[[ "$CURRENT_DB_MEM" != "$AUTOMEM" ]] && {
sed -i "s|^innodb_buffer_pool_size =.*|innodb_buffer_pool_size = $AUTOMEM|" "$CONF"
service mysql restart
}

# RESTART PHP
[[ "$PHPTHREADS" != "$CURRENT_THREADS" ]] || \
Expand Down
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

[v1.7.1](https://github.com/nextcloud/nextcloudpi/commit/a077130) (2019-02-22) lamp: adjust mariadb parameters
[v1.8.2](https://github.com/nextcloud/nextcloudpi/commit/3315e2e) (2019-02-23) nc-limits: autocalculate database memory

[v1.8.1 ](https://github.com/nextcloud/nextcloudpi/commit/2a0dc38) (2019-02-22) lamp: adjust mariadb parameters

[v1.8.0 ](https://github.com/nextcloud/nextcloudpi/commit/602b3f2) (2019-02-23) add nc-maintenance-mode (#809)

[v1.7.0](https://github.com/nextcloud/nextcloudpi/commit/5e1ea77) (2019-02-17) add nc-restore-snapshot

Expand Down

0 comments on commit bf1fc1f

Please sign in to comment.