less0 -> at_least_one

This commit is contained in:
Alexandre Aubin 2020-04-05 22:37:24 +02:00
parent b7a5847c30
commit a4d28efa6c

View file

@ -311,7 +311,7 @@ ynh_get_scalable_phpfpm () {
# Get the total of RAM available, except swap. # Get the total of RAM available, except swap.
local max_ram=$(ynh_check_ram --no_swap) local max_ram=$(ynh_check_ram --no_swap)
less0() { at_least_one() {
# Do not allow value below 1 # Do not allow value below 1
if [ $1 -le 0 ] if [ $1 -le 0 ]
then then
@ -331,7 +331,7 @@ ynh_get_scalable_phpfpm () {
then then
php_max_children=$(( $php_max_children / 2 )) php_max_children=$(( $php_max_children / 2 ))
fi fi
php_max_children=$(less0 $php_max_children) php_max_children=$(at_least_one $php_max_children)
# To not overload the proc, limit the number of children to 4 times the number of cores. # To not overload the proc, limit the number of children to 4 times the number of cores.
local core_number=$(nproc) local core_number=$(nproc)
@ -345,13 +345,13 @@ ynh_get_scalable_phpfpm () {
then then
# Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager
php_min_spare_servers=$(( $php_max_children / 8 )) php_min_spare_servers=$(( $php_max_children / 8 ))
php_min_spare_servers=$(less0 $php_min_spare_servers) php_min_spare_servers=$(at_least_one $php_min_spare_servers)
php_max_spare_servers=$(( $php_max_children / 2 )) php_max_spare_servers=$(( $php_max_children / 2 ))
php_max_spare_servers=$(less0 $php_max_spare_servers) php_max_spare_servers=$(at_least_one $php_max_spare_servers)
php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 ))
php_start_servers=$(less0 $php_start_servers) php_start_servers=$(at_least_one $php_start_servers)
else else
php_min_spare_servers=0 php_min_spare_servers=0
php_max_spare_servers=0 php_max_spare_servers=0