Phpswitcher 5.0.5 Bug - Default php pool config and sockets gets deleted when creating a new customer

  • Hello,


    if I delete a customer the fpm/pool.d/customer.conf sill exist.

    The php-fpm does not find the user and refused to start. Independently of the PHP-Version.

    I've to delete them manually and restart the php-fpm.


    Is there a patch ?


    Thanks Olli


    Debian9, morricone, psw 5.05 packaged only.


  • yep, seems the /fpm/pool.d/customer.conf still exist in some cases when a customer account was deleted ...

    any idea how to fix that issue?

    Edited 2 times, last by fulltilt ().

  • could this be the same issue caused by an outdated remove() function?

    see:

    1.5.3-2018120800 - Can't locate object method "remove" via package "iMSCP::File" (iMSCP::Service core library)


    Service.pm from 2018120800 still use the remove() function ....

    Code
    1. iMSCP::File->new( filename => $jobFilePath )->remove();
    2. should be:
    3. iMSCP::File->new( filename => $jobFilePath )->delFile();

    Edited once, last by fulltilt ().

  • the part for removal of the fpm-customer.conf files seems to be missing when the account is completely deleted by an admin or reseller, it works only when a alias or subdomain are deleted from the clientarea. Maybe an extra listener file for admin /reseller user_delete actions could be added to solve this issue?

    Code
    1. sub _deleteObsoleteFpmConfig
    2. {
    3. ....
    4. my $rs = iMSCP::File->new( filename => $phpVersion->{'version_fpm_pool_directory_path'} . "/$moduleData->{'DOMAIN_NAME'}.conf" )->delFile();
    5. ....
    6. }

    Edited 4 times, last by fulltilt ().

  • for now I use monit to monitor the php services pid ... this needs to be adjusted depending use of packaged or compiled php version ... added to /etc/monit/monitrc

  • Problem B - exists since 5.0.3 and still in 5.0.5:

    When switching a site back to the default phpversion or when creating a new customer with default phpversion, the same problem from above now hits all pages wich are using the default php version. The command perl /var/www/imscp/engine/imscp-rqst-mngr -v is not able to fix this problem, but with a fast reconfiguration perl /var/www/imscp/engine/setup/imscp-reconfigure -danv this problem gets hotfixed aswell in the meantime. But it seems like there is still another problem hidden in the phpswitcher.

    Spent some time trying to work on this, and found a probable cause and a fix for it. I could not cause the default PHP version pool configurations to be deleted on a domain creation or deletion. However, there is a bug related to the php_compiler.pl, which causes all the pool configurations to be wiped for the default PHP version.


    The issue


    When using the compiler, all the PHP versions processed get changed to either toadd or tochange state. Then, run-method on backend/PhpSwitcher.pm will run _deconfigureFpm for all the affected PHP versions.


    On the very last line of _deconfigureFpm, there is a function call:

    unlink grep !/www\.conf$/, glob "$phpVersion->{'version_fpm_pool_directory_path'}/*.conf"; This will delete all the pool configs besides the www.conf. This is fine for PHP versions other than default. run will then call _scheduleDomainsChange, which will change the status of domains, subdomains, aliasses and subdomain aliasses to tochange if they have a non-default PHP-version. When the backend tasks are run, the pool configurations get recreated for these.


    So, in summary, all PHP versions will have their pool configurations deleted, but only the ones with non-default PHP-version gets recreated. Because the default PHP service is not reloaded, the issue will not be visible until someone adds a domain or changes back to default PHP version.


    The solution


    The fix seems to be quite simple. You have to edit backend/PhpSwitcher.pm and change the end (should be line 1787) of _deconfigureFpm from

    Code
    1. unlink grep !/www\.conf$/, glob "$phpVersion->{'version_fpm_pool_directory_path'}/*.conf";

    to

    Code
    1. # Prevent default PHP file configurations from being destroyed
    2. return if $phpVersion->{'version_is_default'};
    3. unlink grep !/www\.conf$/, glob "$phpVersion->{'version_fpm_pool_directory_path'}/*.conf";

    Disclaimer: use at your own risk.


    Additional help


    If you managed to end up in a state where all the pool configurations for default PHP versions are gone, there is a faster alternative to perl /var/www/imscp/engine/setup/imscp-reconfigure -danv. Basically, you need to change the state of domains, subdomains, aliasses and subdomain aliasses with default PHP version to tochange, and run the request manager with /var/www/imscp/engine/imscp-rqst-mngr or from admin via Debugger -> Run Tasks. To change all the states, you can run these SQL queries:

    Disclaimer: use at your own risk.