AlternC / alternc-php-fpm

PHP 5.6/7.x/... FPM module for AlternC
GNU General Public License v2.0
1 stars 6 forks source link

phpx.x-fpm services fail to reload #23

Open Mazamazine opened 1 year ago

Mazamazine commented 1 year ago

If the services are not running, /usr/lib/alternc/php7-fpm will fail with, for instance:

Reloading phpx.x-fpm configuration (via systemctl): phpx.x-fpm.servicephpx.x-fpm.service is not active, cannot reload.
 failed!

An easy way is to add an OR in the reload call to ensure the service is started if not running: passthru("/etc/init.d/php".$service."-fpm reload || /etc/init.d/php".$service."-fpm start");

Which works properly:

Reloading php8.2-fpm configuration (via systemctl): php8.2-fpm.servicephp8.2-fpm.service is not active, cannot reload.                                                          
 failed!
Starting php8.2-fpm (via systemctl): php8.2-fpm.service.
camlafit commented 1 year ago

Hello

should be solved with https://github.com/AlternC/alternc-php-fpm/blob/issue-18/src/usr/lib/alternc/php7-fpm#L76

Is it enough ?

Mazamazine commented 1 year ago

It doesn't work because the unit exists even if the service is dead. The script checks for /etc/php/$version/fpm/pool.d so it will try anyway for any installed version:

root@staging-alternc:/usr/lib/alternc# service php5.6-fpm status | grep 'Active:'
   Active: inactive (dead) since Tue 2023-04-25 15:09:58 EDT; 2min 39s ago
root@staging-alternc:/usr/lib/alternc# ls /etc/init.d/php*
/etc/init.d/php5.6-fpm  /etc/init.d/php7.1-fpm  /etc/init.d/php7.3-fpm  /etc/init.d/php8.0-fpm  /etc/init.d/php8.2-fpm
/etc/init.d/php7.0-fpm  /etc/init.d/php7.2-fpm  /etc/init.d/php7.4-fpm  /etc/init.d/php8.1-fpm
root@staging-alternc:/usr/lib/alternc# ./php7-fpm
Alternc-nss: updating files in /var/lib/extrausers/
2023-04-25 15:10:41 Log of php7-fpm
Creating php 5.6 fpm pool for user test
Reloading php5.6-fpm configuration (via systemctl): php5.6-fpm.servicephp5.6-fpm.service is not active, cannot reload.
 failed!

So here, in a case where php5.6-fpm was not running, adding a sub-domain on 5.6 fails (silently from the user side, since it's from the cron). And the page will show a 503.

camlafit commented 1 year ago

Hello

Ok we must improve this behavior and do a check between sysV and systemd. I'll do a next try to manage this two use case. If service is disabled script should not start it . We initial suggestion this choice will be ignored , and start forced.