nextcloud / vm

💻☁📦 The Nextcloud VM (virtual machine appliance), Home/SME Server and scripts for RPi (4). Community developed and maintained.
https://download.nextcloudvm.com
GNU General Public License v3.0
1.3k stars 656 forks source link

Calculate the values of PHP-FPM based on the amount of RAM available fails to work properly, prevent service from restarting #943

Closed AetherCollective closed 5 years ago

AetherCollective commented 5 years ago

Steps to reproduce

  1. Create a blank VM with Ubuntu Server 18.04
  2. Install using script at https://github.com/nextcloud/vm/blob/master/nextcloud-startup-script.sh
  3. Fails at this section of script: (Line 546)
if home_sme_server
then
    # Add specific values to PHP-FPM based on 16 GB RAM
    check_command sed -i "s|pm.max_children.*|pm.max_children = 307|g" $PHP_POOL_DIR/nextcloud.conf
    check_command sed -i "s|pm.start_servers.*|pm.start_servers = 30|g" $PHP_POOL_DIR/nextcloud.conf
    check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 20|g" $PHP_POOL_DIR/nextcloud.conf
    check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 257|g" $PHP_POOL_DIR/nextcloud.conf
    restart_webserver
else
    # Calculate the values of PHP-FPM based on the amount of RAM available (minimum 2 GB or 8 children)
    calculate_php_fpm

    # Run again if values are reset on last run
    calculate_php_fpm
fi

Expected behaviour

Properly update values

Actual behaviour

Values updated cause php7.2 service to fail to restart.

Server configuration

Nextcloud server version: (see your admin page) 16.0.4

Server OS (Ubuntu server is default) Ubuntu Server 18.04 LTS

How did you install the VM? (Scripted install from master OR Released version)

Network

Do you use DHCP? Yes, static at Router level.

Is port 80 and/or 443 open? Yes

Logs / Screenshots

Log file (/mnt/ncdata/nextcloud.log)

None available

Installation log (command output)

None available

Screenshoots

None available

enoch85 commented 5 years ago

Thanks for your issue.

Are you trying to install your own NUC? This value is optimized for the Home SME/Server and should only be run (hence if home_sme_server ...) if you are running the hardware of the NUC. Is this being used in some other config as well you mean?

enoch85 commented 5 years ago

Also, how much RAM did you add to the VM?

AetherCollective commented 5 years ago

On one instance I gave it 20 GB (1024MB*20). On another instance, I ran on hardware (not a VM) and gave it the full 24 GB.

Both instances caused the reported issue.

AetherCollective commented 5 years ago

My bad, I clicked the wrong button.

enoch85 commented 5 years ago

I just installed (and released) a new version with the latest scripts and it worked without any issues, so I would need more information to debug this.

Can you tell me exactly which versions you are running and steps to reproduce?

Thanks!

AetherCollective commented 5 years ago

Nextcloud installed yesterday, so would have been commit: 3dc15ef236ba21430b01c1310930b765840093c1

AetherCollective commented 5 years ago

Steps were as described above on hardware (non-vm) 24 GB ram

enoch85 commented 5 years ago

OK, can you please try again just to see if that commit fixed it?

I'm still not understand why it thinks it's a Home SME/Server, because that's the only time those special values should be run: https://github.com/nextcloud/vm/blob/master/lib.sh#L977-L995 It checks for specific hardware and only runs if that exists.

AetherCollective commented 5 years ago

Yup I saw that. I don't know why either. I already have my server set up and it would be inconvenient to wipe and reinstall just to test this bug when I already fixed it by editing the config files in that pool.d directory. If you want I can test in a VM on a different system with different hardware. That cool with you?

enoch85 commented 5 years ago

Yeah sure, it would be nice to confirm that the if check actually works on any server - only running when the NUC hardware is used.

AetherCollective commented 5 years ago

Sure thing. I'll be heading to bed soon and I have plans to hang out with friends when I wake up but after that I'll be all over it. I'll get back with you in 24 hours, 48 hours tops if I am exhausted afterwards.

enoch85 commented 5 years ago

Thanks!

AetherCollective commented 5 years ago

@supra89t , you can fix by editing your nextcloud.conf file: nano /etc/php/7.2/fpm/pool.d/nextcloud.conf Make sure pm.max_spare_servers is less or equal to pm.max_children

enoch85 commented 5 years ago

@supra89t Before you do that, please run the following script and post the outout:

#!/bin/bash

# Get all the variables
. <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)

# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=1
debug_mode

if home_sme_server
then
    # Add specific values to PHP-FPM based on 16 GB RAM
    check_command sed -i "s|pm.max_children.*|pm.max_children = 307|g" $PHP_POOL_DIR/nextcloud.conf
    check_command sed -i "s|pm.start_servers.*|pm.start_servers = 30|g" $PHP_POOL_DIR/nextcloud.conf
    check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 20|g" $PHP_POOL_DIR/nextcloud.conf
    check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 257|g" $PHP_POOL_DIR/nextcloud.conf
    restart_webserver
else
    # Calculate the values of PHP-FPM based on the amount of RAM available (minimum 2 GB or 8 children)
    calculate_php_fpm

    # Run again if values are reset on last run
    calculate_php_fpm
fi

Thanks!

supra89t commented 5 years ago

@enoch85

ncadmin@cloud:~$ sudo bash script.sh
+ home_sme_server
+ lshw -c system
+ grep -q NUC8i3BEH
+ '[' -n '' ']'
+ return 1
+ calculate_php_fpm
+ min_max_children=8
+ min_start_servers=20
+ min_max_spare_servers=35
++ grep pm.start_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_START=3
++ grep pm.max_spare_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_MAX=118
++ grep pm.min_spare_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_MIN=2
+ CURRENT_SUM=123
+ average_php_memory_requirement=50
++ awk '/MemAvailable/ {printf "%d", $2/1024}' /proc/meminfo
+ available_memory=5525
+ PHP_FPM_MAX_CHILDREN=110
+ print_text_in_color '\e[0;96m' 'Automatically configures pm.max_children for php-fpm...'
+ printf '%b%s%b\n' '\e[0;96m' 'Automatically configures pm.max_children for php-fpm...' '\e[0m'
Automatically configures pm.max_children for php-fpm...
+ '[' 110 -lt 8 ']'
+ check_command sed -i 's|pm.max_children.*|pm.max_children = 110|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ sed -i 's|pm.max_children.*|pm.max_children = 110|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ restart_webserver
+ check_command systemctl restart apache2
+ systemctl restart apache2
+ is_this_installed php7.2-fpm
+ dpkg-query -W '-f=${Status}' php7.2-fpm
+ grep -q 'ok installed'
+ return 0
+ check_command systemctl restart php7.2-fpm.service
+ systemctl restart php7.2-fpm.service
Job for php7.2-fpm.service failed because the control process exited with error code.
See "systemctl status php7.2-fpm.service" and "journalctl -xe" for details.
+ print_text_in_color '\e[0;96m' 'Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!'
+ printf '%b%s%b\n' '\e[0;96m' 'Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!' '\e[0m'
Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!
+ print_text_in_color '\e[0;91m' 'systemctl restart php7.2-fpm.service failed'
+ printf '%b%s%b\n' '\e[0;91m' 'systemctl restart php7.2-fpm.service failed' '\e[0m'
systemctl restart php7.2-fpm.service failed
+ exit 1
AetherCollective commented 5 years ago

Been working on the VM. Gave it 8 GB. Different install options that I normally give it. Gave it all apps on phase 1, only automatic update on phase 2.

Phase 1: image

Phase 2 image

Commit 17d714ad8673876d2e97944f8ef4cf6a662369ac Looks right to me

supra89t commented 5 years ago

Is 8GB too much? I have lots of room RAM and Disk wise. I have fail2ban, onlyoffice, elastic search and preview generator installed. I notice that Preview Gen takes a lot of ram and does not free it up once its completed. So I was giving more ram for head room so that the cloud does not slow down.

supra89t commented 5 years ago

@BetaLeaf

Just rebuilt it again this time with 6GB RAM,

Phase 1:

[Nextcloud]
user = www-data
group = www-data
listen = /run/php/php"7.2"-fpm.nextcloud.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
; max_children is set dynamically with calculate_php_fpm()
pm.max_children = 107
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 77
env[HOSTNAME] = cloud
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
security.limit_extensions = .php
php_admin_value [cgi.fix_pathinfo] = 1

; Optional
; pm.max_requests = 2000

Should I modify this before continuing ?

AetherCollective commented 5 years ago

My hardware has 24 GB, with all the bells and whistles. Commited: Average 12.25 GB; Max 14 GB Available: 20 GB

Meaning my system is using 4GB. I also run a Plex Media Server as well. I don't think there is any such thing as too much, esp when you already have the RAM

AetherCollective commented 5 years ago
pm.max_children = 107
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 77

Looks acceptable. Shouldn't give you any problems.

supra89t commented 5 years ago
pm.max_children = 107
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 77

Looks acceptable. Shouldn't give you any problems.

Ok, starting phase 2

supra89t commented 5 years ago

@BetaLeaf

Same issue:

Configuring automatic updates...
Do you want to enable automatic updates? ([y]es or [N]o): y
Do you want to reboot your server after every update? ([y]es or [N]o): y
Automatically configures pm.max_children for php-fpm...
Job for php7.2-fpm.service failed because the control process exited with error code.
See "systemctl status php7.2-fpm.service" and "journalctl -xe" for details.
Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!
systemctl restart php7.2-fpm.service failed
root@cloud:~#

I checked just before doing the autoupdate script and the settings in the nextcloud.conf were the same.

Once it crashed, opened the conf again and this is what I found:

[Nextcloud]
user = www-data
group = www-data
listen = /run/php/php"7.2"-fpm.nextcloud.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
; max_children is set dynamically with calculate_php_fpm()
pm.max_children = 65
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 77
env[HOSTNAME] = cloud.bohbotsystems.ca
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
security.limit_extensions = .php
php_admin_value [cgi.fix_pathinfo] = 1

; Optional
; pm.max_requests = 2000
enoch85 commented 5 years ago

@BetaLeaf Thanks for helping on this!

@supra89t Could you please run journalctl -xe after it crashed?

enoch85 commented 5 years ago

@supra89t There is no php-fpm related error in there.

Please run that command directly after the php-fpm service failed to restart.

Thanks!

enoch85 commented 5 years ago

@supra89t Btw, you might remove sensetive information from the output. Right now I can access your RADIUS something...

enoch85 commented 5 years ago

@supra89t Also, are you trying to use the scripts on a non-clean server? Meaning, are there stuff already installed?

supra89t commented 5 years ago

@supra89t Also, are you rying to use the scripts on a non-clean server? Meaning, are there stuff already installed?

Nope, clean image.

Doing it again now to get you the error.

supra89t commented 5 years ago

I did not install those, thank you for pointing it out. I will call my ISP and ask for a new IP.

Please do delete the msg with the info :)

supra89t commented 5 years ago

I'm totally confused at the moment... In Phase 1 I selected all the addons, Phase 2 only fail2ban.

After install I selected Modsecurity and added security and auto updates. It passed through no problems and is booted up. I Ill get a new IP and activate SSL, perhaps it was bugged.

enoch85 commented 5 years ago

@supra89t So the issue is gone?

supra89t commented 5 years ago

@supra89t So the issue is gone?

Yes, could be be something from the apps scripts that causing the file to change during the update process? I'm currently waiting for my new IP to propagate and my new cname since letsencrypt told me i activated it too many times...

enoch85 commented 5 years ago

I just installed a new VM on Digitalocean, and everything worked, without an changes (that PR isn't merged yet).

I'm still bugged about this...

supra89t commented 5 years ago

Ok,

I got it to fail again. As follows;

Used UFW to deny all traffic except ports needed.

Phase 1: ALL OPTIONS SELECTED

Phase 2: Fail2ban Onlyoffice ElasticSearch PreviewGenerator

All completed without errors and using letsencrypt from the install script.

End of Phase 2: ModSecurity - Selected ExtraSecurity - Selected StaticIP - Not Selected Automatic updates - Selected

Security installed without active defence

Auto updates... fails yet again

---------------------------------------------------------------------------------------------------------------
Configuring automatic updates...
Do you want to enable automatic updates? ([y]es or [N]o): y
Do you want to reboot your server after every update? ([y]es or [N]o): y
Automatically configures pm.max_children for php-fpm...
Job for php7.2-fpm.service failed because the control process exited with error code.
See "systemctl status php7.2-fpm.service" and "journalctl -xe" for details.
Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!
systemctl restart php7.2-fpm.service failed
root@nextcloud:~# sudo journalctl -xe
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has finished shutting down.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit apache2.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has begun starting up.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: Started The Apache HTTP Server.
-- Subject: Unit apache2.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has finished starting up.
--
-- The start-up result is RESULT.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: Stopping The PHP 7.2 FastCGI Process Manager...
-- Subject: Unit php7.2-fpm.service has begun shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit php7.2-fpm.service has begun shutting down.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: Stopped The PHP 7.2 FastCGI Process Manager.
-- Subject: Unit php7.2-fpm.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit php7.2-fpm.service has finished shutting down.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
-- Subject: Unit php7.2-fpm.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit php7.2-fpm.service has begun starting up.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca php-fpm7.2[50083]: [16-Sep-2019 10:34:52] ALERT: [pool Nextcloud] pm.min_spare_servers(2) and pm.max_spare_servers(77) cannot be greater than pm.max_children(66)
Sep 16 10:34:52 nextcloud.bohbotsystems.ca php-fpm7.2[50083]: [16-Sep-2019 10:34:52] ERROR: failed to post process the configuration
Sep 16 10:34:52 nextcloud.bohbotsystems.ca php-fpm7.2[50083]: [16-Sep-2019 10:34:52] ERROR: FPM initialization failed
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: php7.2-fpm.service: Main process exited, code=exited, status=78/n/a
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: php7.2-fpm.service: Failed with result 'exit-code'.
Sep 16 10:34:52 nextcloud.bohbotsystems.ca systemd[1]: Failed to start The PHP 7.2 FastCGI Process Manager.
-- Subject: Unit php7.2-fpm.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit php7.2-fpm.service has failed.
--
-- The result is RESULT.
Sep 16 10:35:01 nextcloud.bohbotsystems.ca cron[1470]: (root) RELOAD (crontabs/root)
Sep 16 10:35:01 nextcloud.bohbotsystems.ca CRON[50169]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 16 10:35:01 nextcloud.bohbotsystems.ca CRON[50170]: pam_unix(cron:session): session opened for user www-data by (uid=0)
Sep 16 10:35:01 nextcloud.bohbotsystems.ca CRON[50172]: (www-data) CMD (php -f /var/www/nextcloud/cron.php > /dev/null 2>&1)
Sep 16 10:35:01 nextcloud.bohbotsystems.ca CRON[50171]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Sep 16 10:35:01 nextcloud.bohbotsystems.ca CRON[50169]: pam_unix(cron:session): session closed for user root
Sep 16 10:35:02 nextcloud.bohbotsystems.ca CRON[50170]: pam_unix(cron:session): session closed for user www-data
Sep 16 10:35:12 nextcloud.bohbotsystems.ca sudo[50242]:     root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/journalctl -xe
Sep 16 10:35:12 nextcloud.bohbotsystems.ca sudo[50242]: pam_unix(sudo:session): session opened for user root by ncadmin(uid=0)
AetherCollective commented 5 years ago

I reinstalled my server (hardware) today and using the exact same setup as I was using (before that previously caused the issue) and can confirm the issue is still present.

Phase one set spare server to 439 and children to 469. Phase two set spare server to 439 and children to 402.

enoch85 commented 5 years ago

OK, so this is the issue: pm7.2[50083]: [16-Sep-2019 10:34:52] ALERT: [pool Nextcloud] pm.min_spare_servers(2) and pm.max_spare_servers(77) cannot be greater than pm.max_children(66)

@BetaLeaf Would you mind helping me with a better calculation of php-pfm max/min_spare + max_children

I've been thinking about it but don't have time right now.

Please ping me if you need help! :+1:

enoch85 commented 5 years ago

I just tested again and it works with 24 GB RAM:

+ root_check
+ is_root
+ [[ 0 -ne 0 ]]
+ return 0
+ mkdir -p /var/scripts
+ calculate_php_fpm
+ min_max_children=8
+ min_start_servers=20
+ min_max_spare_servers=35
++ grep pm.start_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_START=3
++ grep pm.max_spare_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_MAX=38
++ grep pm.min_spare_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_MIN=2
+ CURRENT_SUM=43
+ average_php_memory_requirement=50
++ awk '/MemAvailable/ {printf "%d", $2/1024}' /proc/meminfo
+ available_memory=23394
+ PHP_FPM_MAX_CHILDREN=467
+ print_text_in_color '\e[0;96m' 'Automatically configures pm.max_children for php-fpm...'
+ printf '%b%s%b\n' '\e[0;96m' 'Automatically configures pm.max_children for php-fpm...' '\e[0m'
Automatically configures pm.max_children for php-fpm...
+ '[' 467 -lt 8 ']'
+ check_command sed -i 's|pm.max_children.*|pm.max_children = 467|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ sed -i 's|pm.max_children.*|pm.max_children = 467|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ restart_webserver
+ check_command systemctl restart apache2
+ systemctl restart apache2
+ is_this_installed php7.2-fpm
+ dpkg-query -W '-f=${Status}' php7.2-fpm
+ grep -q 'ok installed'
+ return 0
+ check_command systemctl restart php7.2-fpm.service
+ systemctl restart php7.2-fpm.service
+ print_text_in_color '\e[0;92m' 'pm.max_children was set to 467'
+ printf '%b%s%b\n' '\e[0;92m' 'pm.max_children was set to 467' '\e[0m'
pm.max_children was set to 467
+ '[' 467 -gt 43 ']'
+ '[' 467 -ge 35 ']'
++ grep pm.start_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ '[' 3 -lt 20 ']'
+ check_command sed -i 's|pm.max_spare_servers.*|pm.max_spare_servers = 437|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ sed -i 's|pm.max_spare_servers.*|pm.max_spare_servers = 437|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ restart_webserver
+ check_command systemctl restart apache2
+ systemctl restart apache2
+ is_this_installed php7.2-fpm
+ dpkg-query -W '-f=${Status}' php7.2-fpm
+ grep -q 'ok installed'
+ return 0
+ check_command systemctl restart php7.2-fpm.service
+ systemctl restart php7.2-fpm.service
+ print_text_in_color '\e[0;92m' 'pm.max_spare_servers was set to 437'
+ printf '%b%s%b\n' '\e[0;92m' 'pm.max_spare_servers was set to 437' '\e[0m'
pm.max_spare_servers was set to 437
+ '[' 467 -lt 43 ']'
+ exit
enoch85 commented 5 years ago

OK, and now I lowered to 1 GB RAM and hit the error.

root@ubuntu:/var/scripts# bash test.sh
+ root_check
+ is_root
+ [[ 0 -ne 0 ]]
+ return 0
+ mkdir -p /var/scripts
+ calculate_php_fpm
+ min_max_children=8
+ min_start_servers=20
+ min_max_spare_servers=35
++ grep pm.start_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_START=3
++ grep pm.max_spare_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_MAX=437
++ grep pm.min_spare_servers /etc/php/7.2/fpm/pool.d/nextcloud.conf
++ awk '{ print $3}'
+ CURRENT_MIN=2
+ CURRENT_SUM=442
+ average_php_memory_requirement=50
++ awk '/MemAvailable/ {printf "%d", $2/1024}' /proc/meminfo
+ available_memory=583
+ PHP_FPM_MAX_CHILDREN=11
+ print_text_in_color '\e[0;96m' 'Automatically configures pm.max_children for php-fpm...'
+ printf '%b%s%b\n' '\e[0;96m' 'Automatically configures pm.max_children for php-fpm...' '\e[0m'
Automatically configures pm.max_children for php-fpm...
+ '[' 11 -lt 8 ']'
+ check_command sed -i 's|pm.max_children.*|pm.max_children = 11|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ sed -i 's|pm.max_children.*|pm.max_children = 11|g' /etc/php/7.2/fpm/pool.d/nextcloud.conf
+ restart_webserver
+ check_command systemctl restart apache2
+ systemctl restart apache2
+ is_this_installed php7.2-fpm
+ dpkg-query -W '-f=${Status}' php7.2-fpm
+ grep -q 'ok installed'
+ return 0
+ check_command systemctl restart php7.2-fpm.service
+ systemctl restart php7.2-fpm.service
Job for php7.2-fpm.service failed because the control process exited with error code.
See "systemctl status php7.2-fpm.service" and "journalctl -xe" for details.
+ print_text_in_color '\e[0;96m' 'Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!'
+ printf '%b%s%b\n' '\e[0;96m' 'Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!' '\e[0m'
Sorry but something went wrong. Please report this issue to https://github.com/nextcloud/vm/issues and include the output of the error message. Thank you!
+ print_text_in_color '\e[0;91m' 'systemctl restart php7.2-fpm.service failed'
+ printf '%b%s%b\n' '\e[0;91m' 'systemctl restart php7.2-fpm.service failed' '\e[0m'
systemctl restart php7.2-fpm.service failed
+ exit 1

SO, the error is that pm.max_spare_servers is not reset if the availibe RAM has decreased.

enoch85 commented 5 years ago

So this needs to be changed:

    check_command sed -i "s|pm.max_children.*|pm.max_children = $PHP_FPM_MAX_CHILDREN|g" $PHP_POOL_DIR/nextcloud.conf
    restart_webserver
    print_text_in_color "$IGreen" "pm.max_children was set to $PHP_FPM_MAX_CHILDREN"
    # Check if the sum of all the current values are more than $PHP_FPM_MAX_CHILDREN and only continue if it is
    if [ $PHP_FPM_MAX_CHILDREN -gt $CURRENT_SUM ]
    then
        # Set pm.max_spare_servers
        if [ $PHP_FPM_MAX_CHILDREN -ge $min_max_spare_servers ]
        then
            if [ "$(grep pm.start_servers $PHP_POOL_DIR/nextcloud.conf | awk '{ print $3}')" -lt $min_start_servers ]
            then
                check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = $((PHP_FPM_MAX_CHILDREN - 30))|g" $PHP_POOL_DIR/nextcloud.conf
                restart_webserver
                print_text_in_color "$IGreen" "pm.max_spare_servers was set to $((PHP_FPM_MAX_CHILDREN - 30))"
            fi
enoch85 commented 5 years ago

@BetaLeaf please test again.

supra89t commented 5 years ago

@enoch85

It works!!!

I ran the exact same config for all my tests and this one worked without an issue. 4Cores 6GB RAM

enoch85 commented 5 years ago

It works!!!

Great! Let's close this issue. :)