Closed iamdevnull closed 1 month ago
Although the validation is successful despite the incorrect variable escaping in config file, the tuning mode is still NOT active. Maybe there is a racecondition between bootstrapping and starting php-fpm over s6. Its only an idea without proof.
root@portal-c4f88c9bc-gr6jn:/app# php-fpm -tt 2>&1 | grep -i "successful"
[04-Oct-2024 11:08:55] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
root@portal-c4f88c9bc-gr6jn:/app# env | grep -i tuning
ENABLE_TUNING_FPM=1
root@portal-c4f88c9bc-gr6jn:/app# php-fpm -i 2>&1 | grep -iE "ondemand|dynamic"
System => Linux portal-c4f88c9bc-gr6jn 6.1.85+ #1 SMP PREEMPT_DYNAMIC Sat Jul 13 14:20:56 UTC 2024 x86_64
Dynamic Library Support => enabled
PHP_PM => ondemand
$_SERVER['PHP_PM'] => ondemand
$_ENV['PHP_PM'] => ondemand
I think the command:
php-fpm -i 2>&1 | grep -iE "ondemand|dynamic"
is misleading because it only shows loaded vars from the os environment which is read by phpinfo.
root@portal-c4f88c9bc-gr6jn:/package/admin/s6/command# env | grep -iE "ondemand|dynamic" PHP_PM=ondemand
Im looking for better command to proof pm mode.
@iamdevnull As you mentioned, your commands can only print out the values of the environment variables set for the container. Have you tried using phpinfo() on the web to check if the PHP-FPM settings have been correctly reflected, instead of using CLI checks?
By the way, I’m not sure which variant of the Docker images you’re using or which environment variables are set for your container. More specific information would help me determine whether this is a bug or simply an incorrect configuration.
After checking again, I believe using [\${PHP_POOL_NAME}]
is correct and there’s no issue with it. I will continue investigating the source of the problem you mentioned to better support you.
@iamdevnull As you mentioned, your commands can only print out the values of the environment variables set for the container. Have you tried using phpinfo() on the web to check if the PHP-FPM settings have been correctly reflected, instead of using CLI checks?
By the way, I’m not sure which variant of the Docker images you’re using or which environment variables are set for your container. More specific information would help me determine whether this is a bug or simply an incorrect configuration.
The command php -i or php-fpm -i
are doing the same as phpinfo()
. But dont waste your time on this topic beacause the ouput represents only variables which were read by linux env.
Default values are based on https://github.com/shinsenter/php/blob/27128323e82b5801b1089d2ba7b1f4785367a69b/src/php/common/php-ini-directives.dockerfile#L78
After checking again, I believe using
[\${PHP_POOL_NAME}]
is correct and there’s no issue with it. I will continue investigating the source of the problem you mentioned to better support you.
Normally, according to
https://www.php.net/manual/en/install.fpm.configuration.php
you define one FPM pool per Vhost.
However, according to
you can also unofficially overwrite parameters.
Normally you could also leave out [\${PHP_POOL_NAME}]
completely, but it makes sense to let bash to substitute the PHP_POOL_NAME variable based on [${PHP_POOL_NAME}]
for better mapping. It would have no functional influence, but a visual one.
The result with [\${PHP_POOL_NAME}]
is like this:
[global]
...
[www]
...
; Generated at 2024-10-04 13:42:57
; Tuning PM
[${PHP_POOL_NAME}]
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 500
The result with [${PHP_POOL_NAME}]
is like this:
[global]
...
[www]
...
; Generated at 2024-10-04 13:42:57
; Tuning PM
[www]
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 500
The second one makes more sense for me.
My problem at moment is that i am tring to get the php-fpm status result over shell because phpinfo()
over apache is not able to show it out of the box. It needs these changes to be able to show it like explained here https://gist.github.com/Jiab77/a9428050ab9bb3f17c5e33343da94fd8.
During debug i saw this file based on https://github.com/shinsenter/php/blob/27128323e82b5801b1089d2ba7b1f4785367a69b/src/php/common/php-ini-directives.dockerfile#L78:
/etc/.docker-env
################
if [ -z ${PHP_PM_STATUS_LISTEN+x} ]; then export PHP_PM_STATUS_LISTEN="/run/php-fpm-status.sock"; fi
if [ -z ${PHP_PM_STATUS_PATH+x} ]; then export PHP_PM_STATUS_PATH="/status/php-fpm"; fi
I can't explain why the PHP-FPM status page got its own variable?
I can't find an option in the documentation to create a separate socket for the status page.
Nevertheless, it would be important to find a way to get the current status of FMP on the shell.
I have now managed to prove on the shell that the dynamic mode works and therefore the var ENABLE_TUNING_FPM
also works:
apt update && apt -y install libfcgi-bin && \
SCRIPT_NAME=/status/php-fpm SCRIPT_FILENAME=/status/php-fpm REQUEST_METHOD=GET QUERY_STRING=full cgi-fcgi -bind -connect /run/php-fpm.sock | grep -iE 'ondemand|dynamic'
process manager: dynamic
watch 'SCRIPT_NAME=/status/php-fpm SCRIPT_FILENAME=/status/php-fpm REQUEST_METHOD=GET QUERY_STRING=full cgi-fcgi -bind -connect /run/php-fpm.sock'
Based on my debug setting ENABLE_TUNING_FPM to 1 is working technically but the config file looks damaged and the mode is not taking effect:
/usr/local/etc/php-fpm.d/zz-generated-settings.conf
based on:
src/php/common/rootfs/etc/hooks/bootstrap/10-create-conf
the escaping should be changed in line 41 from
[\${PHP_POOL_NAME}]
to[${PHP_POOL_NAME}]