phpdocker-io/phpdocker.io

Speed up shutdown of php-fpm container via docker-compose down

tobiasmuehl opened this issue · 8 comments

Compared to other dockerfiles the ones generated from this repo take a long time to shut down.

docker-compose up -d
docker-compose down # takes up to 10 seconds for php-fpm to stop

Couldn't find out which option/flag to set to speed this up - any ideas?

I suspect the process_control_timeout directive for php-fpm has different values on the official php images vs debian packaged ones. The default value according to docs is 0. I'll have a look.

Looks like for some reason the fpm process is launched via sh -c even though the entry point is null. Therefore the stop signal goes to sh and not fpm. The reason it's taking 10s is because it's in fact timing out at which point docker nukes it from orbit. Trying to get to the bottom of it.

So sh and bash both swallow any SIG*** signals. We do need at the moment bash or sh to correctly run the sed filter that strips out a lot of crap fpm adds to its own stdout (eg your logs come out this way and would get polluted by it). Looking at ways around this.

Basically it removes the pool stuff on a log entry such as

php-fpm_1   | [15-Jul-2019 15:32:39] WARNING: [pool www] child 6 said into stdout: "[2019-07-15 15:32:39] php.INFO: User Deprecated: The "ApiPlatform\Core\EventListener\ExceptionListener::onKernelException()" method will require a new "EventDispatcherInterface $eventDispatcher" argument in the next major version of its parent class "Symfony\Component\HttpKernel\EventListener\ExceptionListener", not defining it is deprecated. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"ApiPlatform\\Core\\EventListener\\ExceptionListener::onKernelException()\" method will require a new \"EventDispatcherInterface $eventDispatcher\" argument in the next major version of its parent class \"Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener\", not defining it is deprecated. at /application/vendor/symfony/debug/DebugClassLoader.php:200)"} []"

@tobiasmuehl this is now fixed in php 7.3. Thankfully they added decorate_workers_output to fpm's config that does the same thing the sed workaround did. This however is not available on php 7.2 and below. Which version are you using?

@luispabon Thanks for the quick reply and sorry for the slow reply on my part. I'm on 7.3, so replacing sed for decorate_workers_output is entirely possible for my usecase.

Can confirm. Excellent!

Great stuff, thanks for reporting 👍