Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions bin/ncp/CONFIG/nc-limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ tmpl_php_threads() {
[[ $PHPTHREADS -eq 0 ]] && PHPTHREADS=$(( TOTAL_MEM / ( 100 * 1024 * 1024 ) ))
# Minimum 16
[[ $PHPTHREADS -lt 16 ]] && PHPTHREADS=16
echo -n "$PHPTHREADS"
echo -n "$PHPTHREADS"
}

tmpl_php_max_requests() {
local PHPMAXREQUESTS="$(find_app_param nc-limits PHPMAXREQUESTS)"
[[ $PHPMAXREQUESTS -eq 0 ]] && PHPMAXREQUESTS=500
echo -n "$PHPMAXREQUESTS"
}

configure()
Expand All @@ -59,20 +65,20 @@ configure()
file /bin/bash | grep 64-bit > /dev/null || TOTAL_MEM="$(( 1024 * 1024 * 1024 * 4 ))"
local AUTOMEM=$(( TOTAL_MEM * 75 / 100 ))

# MAX FILESIZE

# MAX PHP MEMORY
# PHP MAX FILESIZE & PHP MAX MEMORY
local require_fpm_restart=false
local CONF=/etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini
local CONF_VALUE="$(cat "$CONF" 2> /dev/null || true)"
echo "Using $(tmpl_php_max_filesize) for PHP max filesize"
echo "Using $(tmpl_php_max_memory) for PHP max memory"
install_template "php/90-ncp.ini.sh" "$CONF"
[[ "$CONF_VALUE" == "$(cat "$CONF")" ]] || require_fpm_restart=true

# MAX PHP THREADS
# PHP THREADS & PHP MAX REQUESTS
local CONF=/etc/php/${PHPVER}/fpm/pool.d/www.conf
CONF_VALUE="$(cat "$CONF" 2> /dev/null || true)"
echo "Using $(tmpl_php_threads) PHP threads"
echo "Using $(tmpl_php_max_requests) for PHP max requests"
install_template "php/pool.d.www.conf.sh" "$CONF"
[[ "$CONF_VALUE" == "$(cat "$CONF")" ]] || require_fpm_restart=true

Expand Down
13 changes: 10 additions & 3 deletions etc/ncp-config.d/l10n/nc-limits/de.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{"translations": {
"nc-limits": "Systembegrenzungen"
}}
{
"translations": {
"nc-limits": "Systembegrenzungen",
"MAXFILESIZE": "Maximale Dateigröße",
"MEMORYLIMIT": "Speicherlimit",
"PHPTHREADS": "PHP-Threads",
"PHPMAXREQUESTS": "Max. Anfragen vor Worker-Rotation",
"REDISMEM": "Redis-Speicher"
}
}
1 change: 1 addition & 0 deletions etc/ncp-config.d/l10n/nc-limits/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"MAXFILESIZE":"Tamaño máximo de archivo en subida",
"MEMORYLIMIT": "Límite de memoria",
"PHPTHREADS": "Hilos PHP",
"PHPMAXREQUESTS": "Máx. de solicitudes antes de rotar el worker",
"REDISMEM": "Memoria Redis",
"Set PHP threads to 0 in order to use all cores": "Configura los hilos a 0 para usar todos los cores",
"nc-limits": "nc-limits"
Expand Down
1 change: 1 addition & 0 deletions etc/ncp-config.d/l10n/nc-limits/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"MAXFILESIZE":"Tamanho máximo de arquivo para upload",
"MEMORYLIMIT": "Limite de memória",
"PHPTHREADS": "THREADS PHP",
"PHPMAXREQUESTS": "Máx. de requisições antes da rotação do worker",
"REDISMEM": "Memória Redis",
"Set PHP threads to 0 in order to use all cores": "Configure as THREADS PHP à 0 para usar todas as cores",
"nc-limits": "nc-limites"
Expand Down
10 changes: 9 additions & 1 deletion etc/ncp-config.d/l10n/nc-limits/ru.json
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{"translations":{"MAXFILESIZE":"Максимальный размер файла","MEMORYLIMIT":"Ограничение памяти","PHPTHREADS":"PHP потоки","REDISMEM":"REDIS память"}}
{
"translations": {
"MAXFILESIZE": "Максимальный размер файла",
"MEMORYLIMIT": "Ограничение памяти",
"PHPTHREADS": "PHP потоки",
"PHPMAXREQUESTS": "Макс. запросов до ротации воркера",
"REDISMEM": "REDIS память"
}
}
1 change: 1 addition & 0 deletions etc/ncp-config.d/l10n/nc-limits/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"MAXFILESIZE": "最大文件大小(<=2G)",
"MEMORYLIMIT": "內存限制",
"PHPTHREADS": "PHP線程",
"PHPMAXREQUESTS": "Worker 重启前的最大请求数",
"REDISMEM": "REDIS記憶大小",
"Examples: 200M or 2G. Write 0 for autoconfig": "例如:輸入200M或是2G。若要讓系統自行設定,請輸入0",
"nc-limits": "修改NCP系統限制"
Expand Down
7 changes: 7 additions & 0 deletions etc/ncp-config.d/nc-limits.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
"default": "0",
"suggest": "0"
},
{
"id": "PHPMAXREQUESTS",
"name": "Max. requests before worker rotation",
"value": "500",
"default": "500",
"suggest": "500"
},
{
"id": "REDISMEM",
"name": "Redis memory",
Expand Down
4 changes: 3 additions & 1 deletion etc/ncp-templates/php/pool.d.www.conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ PHPVER="${PHPVER?ERROR: PHPVER variable unset!}"
if [[ "$1" == "--defaults" ]] || ! [[ -f "${BINDIR}/CONFIG/nc-limits.sh" ]]
then
echo "INFO: Restoring template to default settings" >&2

PHPTHREADS=16
PHPMAXREQUESTS=500
else
PHPTHREADS="$(source "${BINDIR}/CONFIG/nc-limits.sh"; tmpl_php_threads)"
PHPMAXREQUESTS="$(source "${BINDIR}/CONFIG/nc-limits.sh"; tmpl_php_max_requests)"
fi


Expand All @@ -27,6 +28,7 @@ pm.max_children = ${PHPTHREADS}
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 8
pm.max_requests = ${PHPMAXREQUESTS}
pm.status_path = /status
slowlog = log/\$pool.log.slow
EOF
9 changes: 9 additions & 0 deletions updates/1.58.1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

source /usr/local/etc/library.sh

install_template "php/pool.d.www.conf.sh" "/etc/php/${PHPVER}/fpm/pool.d/www.conf"

systemctl daemon-reload