Skip to content

Commit bf1fc1f

Browse files
committed
nc-limits: autocalculate database memory
1 parent 54565e4 commit bf1fc1f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

bin/ncp/CONFIG/nc-limits.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ configure()
3636
[[ $PHPTHREADS -eq 0 ]] && PHPTHREADS=$( nproc )
3737
[[ $PHPTHREADS -lt 3 ]] && PHPTHREADS=3
3838
echo "Using $PHPTHREADS PHP threads"
39-
sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS|" "$CONF"
40-
sed -i "s|^pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS|" "$CONF"
41-
sed -i "s|^pm.start_servers =.*|pm.start_servers = $PHPTHREADS|" "$CONF"
39+
sed -i "s|^pm =.*|pm = static|" "$CONF"
40+
sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS|" "$CONF"
41+
42+
# DATABASE MEMORY
43+
AUTOMEM=$(( TOTAL_MEM * 40 / 100 ))
44+
local CONF=/etc/mysql/mariadb.conf.d/91-ncp.cnf
45+
local CURRENT_DB_MEM=$(grep "^innodb_buffer_pool_size" "$CONF" | awk '{ print $3 }')
46+
echo "Using $AUTOMEM memory for the database"
47+
[[ "$CURRENT_DB_MEM" != "$AUTOMEM" ]] && {
48+
sed -i "s|^innodb_buffer_pool_size =.*|innodb_buffer_pool_size = $AUTOMEM|" "$CONF"
49+
service mysql restart
50+
}
4251

4352
# RESTART PHP
4453
[[ "$PHPTHREADS" != "$CURRENT_THREADS" ]] || \

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

2-
[v1.7.1](https://github.com/nextcloud/nextcloudpi/commit/a077130) (2019-02-22) lamp: adjust mariadb parameters
2+
[v1.8.2](https://github.com/nextcloud/nextcloudpi/commit/3315e2e) (2019-02-23) nc-limits: autocalculate database memory
3+
4+
[v1.8.1 ](https://github.com/nextcloud/nextcloudpi/commit/2a0dc38) (2019-02-22) lamp: adjust mariadb parameters
5+
6+
[v1.8.0 ](https://github.com/nextcloud/nextcloudpi/commit/602b3f2) (2019-02-23) add nc-maintenance-mode (#809)
37

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

0 commit comments

Comments
 (0)