Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the meaning of php-fpm's catch_workers_output configure item?

Tags:

php

Today when i search how to open php-fpm's error log.I found that a lot of articles say that users should turn on catch_workers_output.But this really confusing me after i read this configure's comment:

catch_workers_output boolean

Redirect worker stdout and stderr into main error log. If not set, stdout and stderr will be redirected to /dev/null according to FastCGI specs.

Default value: no.

And i tried it,the result is:no matter 'on' or 'off',this configure does not affect php's error log action.What decide the log action is the two: log_errors and error_log.

So,what's the function of catch_workers_output?

like image 645
poettian Avatar asked Sep 20 '25 16:09

poettian


1 Answers

If you have a script you would like to run in the background, it can be helpful to finish the request before you continue processing, especially if your work will take a while. For example, running a large report.

In these cases, fastcgi_finish_request() will send a response to the user as if the script has finished. After running this function, any calls to error_log() will be redirected to /dev/null because your server is no longer intercepting error output.

catch_workers_output causes your script's output to be redirected to the main error log. Without this option, you would never get error reports for problems occurring after fastcgi_finish_request.

A closed bug report with more information can be found here:
https://bugs.php.net/bug.php?id=80628

like image 53
Legendary_Linux Avatar answered Sep 22 '25 06:09

Legendary_Linux