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
Provide appropriate mechanism for forking to make GRPC work #3213
Comments
I started looking at Puma source, and figured this is already possible. I think the language in documentation is confusing, and the only way to really know what is executed where is to look at Puma source. I think this example should be incorporated into Puma's documentation as it's not possible to use GRPC in clustered Puma without this config. is_mac = RUBY_PLATFORM.include?('darwin')
on_worker_fork do |index| # Hook name: before_worker_fork
GRPC.prefork unless is_mac
end
after_worker_fork do |index|
GRPC.postfork_parent unless is_mac
end
on_worker_boot do
GRPC.postfork_child unless is_mac
end |
Hey @Nowaker, I'm glad you were able to figure it out. I'm not super happy with the names of our fork hooks either, but it's basically a historical artifact of how they were added on one-by-one over the years. I wonder if a new set of aliases could make this clearer... I'm also not super happy with how we don't have a transcription of the full config in DSL in the |
Hey @nateberkopec. By "transcription," do you mean something like a dsl.md file where we'll have the comments from the dsl.rb file? If so, we can generate that by a script and add some configuration examples(Like the GRPC one). |
Yes, exactly! |
Is your feature request related to a problem? Please describe.
I'm getting this error when trying to use GRPC in Puma in production deployment which is clustered:
To use GRPC, I must call
GRPC.prefork
and thenGRPC.postfork_child
orGRPC.postfork_parent
depending on the context. However, with current Puma DSL, there is no way to know whether I should callpostfork_child
orpostfork_parent
because that information isn't exposed in any way. This isn't enough:Describe the solution you'd like
Two options:
after_worker_fork
to indicate whether the current process is a child or a parent.after_parent_fork
whereGRPC.postfork_parent
would belong to.Or, if my understanding is wrong, and there is a way to execute these three GRPC methods properly, a documentation update is needed, and, ideally, an example on how to handle GRPC forking in Puma.
Describe alternatives you've considered
None.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: