diff options
author | nachoparker <nacho@ownyourbits.com> | 2019-02-23 20:37:27 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2019-03-05 21:22:12 +0300 |
commit | bf1fc1fd87b3efac2c8051e8bf09385f4e34460d (patch) | |
tree | 7bbf45460396781ab1a1f560c6d297f77d0c78ae /bin | |
parent | 54565e476d77cfde958501c38b31213687d60f6d (diff) |
nc-limits: autocalculate database memoryv1.8.3
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ncp/CONFIG/nc-limits.sh | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/bin/ncp/CONFIG/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh index 55e37ed7..219b426e 100644 --- a/bin/ncp/CONFIG/nc-limits.sh +++ b/bin/ncp/CONFIG/nc-limits.sh @@ -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" ]] || \ |