contribsys / faktory_worker_ruby

Faktory worker for Ruby
GNU Lesser General Public License v3.0
214 stars 31 forks source link

Notify the Faktory Server when a process is going quiet and also when terminating #42

Closed scottrobertson closed 4 years ago

scottrobertson commented 4 years ago

1 question for you @mperham around this.

Is sending nil as the current_state ok, or should I add a conditional to only send that when there is no state. Seems like a waste of bytes otherwise, but will let you answer before I add more complexity.

Screenshot 2020-01-11 at 17 25 30 Screenshot 2020-01-11 at 17 25 46

One thing i have noticed is that it still takes a little while for the UI to remove the worker, even after sending the current_state = terminate. Is this by design?

mperham commented 4 years ago

Don't send any state value unless it's quiet or terminate. Any other value is ignored.

Yes, by design processes are only removed once their heartbeat times out. They never explicitly remove themselves, otherwise you might get a process that is removed but still running.

mperham commented 4 years ago

You need to use a global variable to track the current state: "", "quiet" or "terminate". Don't explicitly call beat() once with the state change but rather allow the heartbeat to send the current state with every beat. The line you want to modify is in launcher.rb.

scottrobertson commented 4 years ago

@mperham that makes sense. What class would you keep that current_state in?

mperham commented 4 years ago

I would put it all in launcher. You don’t even need a global if launcher tracks the current state internally.

On Jan 11, 2020, at 09:39, Scott Robertson notifications@github.com wrote:

 @mperham that makes sense. What class would you keep that current_state in?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

scottrobertson commented 4 years ago

@mperham pushed. That seem ok? Basically removed the @done in Launcher in favour of having a @current_state

scottrobertson commented 4 years ago

I tested it manually yeah :) most of the time it will not actually send a "quiet", as it gets to "terminate" too quickly, but yeah, it works.

if terminate is sent, it still seems to show quiet in the UI.

mperham commented 4 years ago

yeah, the only label the UI shows is quiet. A terminating process is, by definition, quiet also.