Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/ncp/CONFIG/nc-limits.sh20
-rw-r--r--etc/ncp-templates/php/pool.d.www.conf.sh32
2 files changed, 44 insertions, 8 deletions
diff --git a/bin/ncp/CONFIG/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh
index 9af4edc3..39d7ae19 100644
--- a/bin/ncp/CONFIG/nc-limits.sh
+++ b/bin/ncp/CONFIG/nc-limits.sh
@@ -33,6 +33,13 @@ tmpl_php_max_filesize() {
[[ "$FILESIZE" == "0" ]] && echo -n "10G" || echo -n "$FILESIZE"
}
+tmpl_php_threads() {
+ local PHPTHREADS="$(find_app_param nc-limits PHPTHREADS)"
+ [[ $PHPTHREADS -eq 0 ]] && PHPTHREADS=$(nproc)
+ [[ $PHPTHREADS -lt 6 ]] && PHPTHREADS=6
+ echo -n "$PHPTHREADS"
+}
+
configure()
{
# Set auto memory limit to 75% of the total memory
@@ -53,13 +60,10 @@ configure()
# MAX PHP THREADS
local CONF=/etc/php/${PHPVER}/fpm/pool.d/www.conf
- local CURRENT_THREADS="$( grep "^pm.max_children" "$CONF" 2>/dev/null | awk '{ print $3 }' || true )"
- [[ $PHPTHREADS -eq 0 ]] && PHPTHREADS=$(nproc)
- [[ $PHPTHREADS -lt 6 ]] && PHPTHREADS=6
- echo "Using $PHPTHREADS PHP threads"
- sed -i "s|^pm =.*|pm = static|" "$CONF"
- sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS|" "$CONF"
- [[ "$PHPTHREADS" == "$CURRENT_THREADS" ]] || require_fpm_restart=true
+ CONF_VALUE="$(cat "$CONF" 2> /dev/null || true)"
+ echo "Using $(tmpl_php_threads) PHP threads"
+ install_template "php/pool.d.www.conf.sh" "$CONF"
+ [[ "$CONF_VALUE" == "$(cat "$CONF")" ]] || require_fpm_restart=true
local CONF=/etc/mysql/mariadb.conf.d/91-ncp.cnf
CONF_VALUE="$(cat "$CONF" 2> /dev/null || true)"
@@ -71,7 +75,7 @@ configure()
# redis max memory
local CONF=/etc/redis/redis.conf
- local CURRENT_REDIS_MEM=$( grep "^maxmemory" "$CONF" | awk '{ print $2 }' )
+ local CURRENT_REDIS_MEM="$( grep "^maxmemory" "$CONF" | awk '{ print $2 }' )"
[[ "$REDISMEM" != "$CURRENT_REDIS_MEM" ]] && {
sed -i "s|^maxmemory .*|maxmemory $REDISMEM|" "$CONF"
chown redis:redis "$CONF"
diff --git a/etc/ncp-templates/php/pool.d.www.conf.sh b/etc/ncp-templates/php/pool.d.www.conf.sh
new file mode 100644
index 00000000..50a65abb
--- /dev/null
+++ b/etc/ncp-templates/php/pool.d.www.conf.sh
@@ -0,0 +1,32 @@
+#! /bin/bash
+
+set -e
+source /usr/local/etc/library.sh
+
+PHPVER="${PHPVER?ERROR: PHPVER variable unset!}"
+
+if [[ "$1" == "--defaults" ]] || ! [[ -f "${BINDIR}/CONFIG/nc-datadir.sh" ]]
+then
+ echo -e "INFO: Restoring template to default settings"
+
+ PHPTHREADS=6
+else
+ PHPTHREADS="$(source "${BINDIR}/CONFIG/nc-limits.sh"; tmpl_php_threads)"
+fi
+
+
+cat <<EOF
+[www]
+user = www-data
+group = www-data
+listen = /run/php/php7.4-fpm.sock
+listen.owner = www-data
+listen.group = www-data
+pm = static
+pm.max_children = ${PHPTHREADS}
+pm.start_servers = 4
+pm.min_spare_servers = 4
+pm.max_spare_servers = 8
+pm.status_path = /status
+slowlog = log/\$pool.log.slow
+EOF