-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix #73886: Handle access log & error log on Docker #2310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It is not clear to me that this is a good idea, I require someone intimately familiar with FPM to tell me it is. |
|
I definitely need to add a close if you use syslog. The same as in #1432 but for stdout. |
|
I don't know about the fpm internals, but unclean logging is definitely a problem in a Docker setup. |
|
I'm not sure if this can be really useful if you have got multiple running workers (multiple child process running at the same time). Then if they all log to the stdout, you won't be able to see which worker (which executed script) emitted the message. It might be ok if you address this in the app somehow and put it to the message yourself but still think it would be better to handle it in the master and have the option to differentiate it. Also you shouldn't do this for demonised master anyway (you would need to do it only if it's running in the foreground). I think that would be much better to make children stdout and stderr data processing (when |
|
Comment on behalf of bukka at php.net: Closing as it is not correct because it can lead to the interleaving of output from the workers as there is no lock on stdout. The preferred solution will be done using pipe to master as noted above. |
@bukka I know this was 4 years ago, but I still wanted to ask if you came up with a solution or a PoC. If not, I may give it a try, because I would find it really helpful if a dockerized php-fpm-container could log directly to stdout. Related to docker-library/php#358 (comment). |
|
@jaylinski No progress on this. To be honest I completely forgot about it. As it was said it will require some changes in |
|
Just wanted to check if there's new motivation and enthusiasm to fix this? My motivation to get this fixed is to be able to run rootless PHP-FPM Docker containers. If anyone knows a workaround, I'd be eternally grateful. |
|
@bukka to consider an alternative viewpoint: there could be cases where interleaving of output to The concerns do make sense, I think - but the limitation caused by redirecting the stdout file handle to (it's a tricky one: perhaps as a prevention for misconfiguration it makes sense, but it's frustrating in cases where the limitation may not be relevant -- and the containerized configuration which redirects access logs to stderr is probably quite widely-distributed now, and seems like a kind of oddity) |
|
It's an option but I just quickly looked into this and I think it should be doable using a secondary pipe. I bumped the priority of this a bit so I should hopefully manage to try to implement it before 8.3 freeze. |
|
No hurry, honestly - it'd be valuable, but I think (almost? :)) everyone would prefer to see it implemented safely. From a bit of digging into the history of
That'd kinda make sense to me -- the parent process likely doesn't have to follow the same initialization requirements, and so perhaps that's why Even so, it wouldn't entirely explain why the code seems to (and has since 0.6.0.2?) close |
|
So there are two parts where stderr and stdout is handled. The one that is linked and was changed in this PR is for master process init which is then inherited by children. So here it closes the the stdout but then there is |
|
Thank you for the explanation 👍 |
Seems a bit odd to set the stdout to /dev/null making it unusable for logs.
I could not find any reason why it is like this other then the commit b172c7d and 4d005a8 where @tony2001 added the FPM sapi.