-
Notifications
You must be signed in to change notification settings - Fork 30
Access to listener_names within before_service_worker_ready #139
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
Comments
Yes, the service worker has the listeners closed, so that it doesn't appear as listening: pitchfork/lib/pitchfork/http_server.rb Line 930 in ec75abc
You didn't give any detail on what solution you are using for monitoring. Is it Raindrops or something else? For us it isn't too much of a problem because we receive the listeners as environment, so it's not really duplication. Right now you can work around this via: listener_names = nil
after_mold_fork do |_, _|
listener_names = Pitchfork.listener_names
end
before_service_worker_ready do |server, service|
$stderr.puts listener_names
end It's a bit hacky, but I just tested it, it works. I guess Pitchfork could be changed to record |
Hi yea we're using Raindrops, for now we simplified it by hard coding the bind address and stopped relying on How are you monitoring pitchfork? We're using yabeda + prometheus and our collection script now looks a bit like this: pitchfork.workers.set({}, Pitchfork::Info.workers_count)
pitchfork.live_workers.set({}, live_workers_count = Pitchfork::Info.live_workers_count)
if defined?(Raindrops::Linux.tcp_listener_stats)
listener_address = "0.0.0.0:#{ENV.fetch('PORT', 3000)}"
stats = Raindrops::Linux.tcp_listener_stats([listener_address])[listener_address]
pitchfork.active_workers.set({}, stats.active)
pitchfork.request_backlog.set({}, stats.queued)
pitchfork.live_capacity.set({}, live_workers_count - stats.active)
pitchfork.live_busy_percentage.set({}, live_workers_count.zero? ? 100.0 : (stats.active * 100.0) / live_workers_count)
end |
More or less the same. Raindrops and some StatsD metrics. One thing you may want to be aware of, is that currently every call to So we use this fork for now: https://github.com/casperisfine/raindrops/tree/file-descriptor-leak |
As for |
What are your thoughts on inlining listener_stats to pitchfork? I've seen you dropped the dependency on raindrops but maybe just inline the function it was providing? Pitchfork.listener_stats And taking care of the leak in the process? This kind of monitoring feels pretty mission critical that everyone will need to do at some point. |
Yeah, I considered some form of that. Was more thinking of doing a companion gem as it could be used by other servers, but I'd like to stop depending on |
We're trying to setup a monitoring service within
before_service_worker_ready
however when we try andPitchfork.listener_names
from within this block we get an error. How do you advise we can do this?The text was updated successfully, but these errors were encountered: