-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
About shutdown judgment of Worker Process #282
Comments
Hey @tmimura39, thanks a lot for looking into this! 🙏 I think your judgement is correct, but it'd apply to all workers currently supervised by the supervisor that receives the I think it'd be nicer to have something like GoodJob, I'll look into it! |
I had completely forgotten that @bdewater had commented about Shopify's job-iteration in #124 (comment), with some quite helpful insight:
I'm going to look into providing a callback like Sidekiq as well. |
Thanks for your patience! I've added a couple of lifecycle hooks, |
Thanks! That is a very good mechanism, but it may not be available for job-iteration. Its lifecycle hooks (#317) are executed only in the Supervisor process. When the Supervisor receives a TERM signal, it sends a TERM signal to the fork process including the Worker. solid_queue/lib/solid_queue/supervisor.rb Line 97 in a17a08b
It would be nice to be able to set some kind of hook when this TERM signal is received in the Worker process. I implemented and tested it this way. module JobIteration
module InterruptionAdapters
module SolidQueueAdapter
class << self
attr_accessor :stopping
# This is called by the Worker process.
# Since the on_stop hook does not work within the Worker process, `sopping` is left unset.
def call
stopping
end
end
end
# on_stop hook works correctly. (in Supervisor Process)
SolidQueue.on_stop do
JobIteration::InterruptionAdapters::SolidQueueAdapter.stopping = true
end
register(:solid_queue, SolidQueueAdapter)
end
end On second thought, The “graceful_termination.solid_queue” event is fired only in the Supervisor process, so it seems that the Worker process cannot detect it. Please point out any errors in my perception. |
Ah yes! You're right! I hadn't thought very well about this on the job-iteration gem; I was following the idea of subscribing to the I'll tweak this! |
Ok, I've got |
Excellent👍 Just what I wanted. Thank you so much! # frozen_string_literal: true
require "job-iteration"
module JobIteration
module InterruptionAdapters
module SolidQueueAdapter
class << self
attr_accessor :stopping
def call
stopping
end
end
end
SolidQueue.on_worker_stop do
JobIteration::InterruptionAdapters::SolidQueueAdapter.stopping = true
end
register(:solid_queue, SolidQueueAdapter)
end
end |
Awesome! Thanks a lot. I'll merge this and release a new version with these changes 🙏 |
Done! Version 0.7.1 has these new hooks. Going to close this one then, but let me know if you encounter any problems 🙏 Thanks again for the patience and help! |
Hi, I am currently trying to get SolidQueue support for the job-iteration gem. Shopify/job-iteration#496
A brief description of job-iteration is as follows
iteration-how-it-works
Here is what needs to be addressed for each Adapter.
I want to determine if the SolidQueue Worker Process is about to receive a
TERM
and shutdown.Is this judgment correct?
GoodJob has implemented a new feature for this.
bensheldon/good_job#1253
I would appreciate your advice as I am unable to determine if the same action is required for SolidQueue.
The text was updated successfully, but these errors were encountered: