Closed openface closed 9 years ago
I don't know for sure, but if I had to guess, the workers would cut off background jobs potentially in the middle of processing. To be sure, I'd probably reach out to the maintainers of unicorn to confirm that worker restarts don't want for child threads to finish as well.
Thanks. Your guess is correct. Here is the followup response from Unicorn maintainer, Eric Wong:
unicorn itself does not know about any threads spawned by the application.
However, you can setup an END/at_exit block in the worker to wait on those threads since unicorn workers perform graceful exit:
at_exit do join_all_threads end
As a follow-up question here, is there a better way of joining on all children threads? Perhaps Celluloid provides a mechanism for doing this in a cleaner way?
Thread.list.each do |t|
t.join if t != Thread.current
end
I'm honestly not sure. The celluloid group light be able to help. All the pools are accessible from the celluloid registry so it'd be easy to get them. But after, that quite sure what you'd do with them after. I'd have to poke through the Celluloid code to get some idea. They've been really responsive to my questions over the years so their Google group is probably a good place to start.
On Thursday, April 23, 2015, Jason Hines notifications@github.com wrote:
As a follow-up question here, is there a better way of joining on all children threads? Perhaps Celluloid provides a mechanism for doing this in a cleaner way?
Thread.list.each do |t| t.join if t != Thread.current end
— Reply to this email directly or view it on GitHub https://github.com/brandonhilkert/sucker_punch/issues/112#issuecomment-95766510 .
_Build a Ruby Gem is available! http://brandonhilkert.com/books/build-a-ruby-gem/?utm_source=gmail-sig&utm_medium=email&utm_campaign=gmail_
So there is currently no way to cleanly terminate celluloid actors. See celluloid/celluloid#557 for discussion.
From Tony Arcieri:
Celluloid used to have a mechanism to perform a clean shutdown, however it seems to have gotten lost along the way in the course of various changes.
557 is definitely the best place to discuss right now.
Will sending a HUP signal to Unicorn cause active running background jobs to be terminated? I understand threads will be terminated when the parent process itself is terminated, but what happens if the application is just reloaded? Sending HUP signal to Unicorn master to reload the application is a common activity and I want to ensure that this will not affect any processing in the background.
Thanks in advance. I plan to look into this and confirm/verify the behavior myself, but thought I'd ask the question here first.