Class: SidekiqErr::Alive
- Inherits:
-
Object
- Object
- SidekiqErr::Alive
- Defined in:
- lib/sidekiq-err/alive.rb
Class Method Summary collapse
Class Method Details
.check?(hostname) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sidekiq-err/alive.rb', line 5 def self.check?(hostname) process_set = Sidekiq::ProcessSet.new # now search for the provided process name in the process set found_process = process_set.find do |process| # we compare the process hostname here as we can know this from k8s land pod # and can use the $HOSTNAME env var in the probe command in the probe specification # # https://stackoverflow.com/questions/58800495/get-a-kubernetes-pods-full-id-from-inside-of-itself-running-container # Note: this aligns to 1 sidekiq container process per pod # this may not hold true in some deployments but should work for most use cases # it's preferable to use pod auto scaling vs running multiple containers in a pod process['hostname'] == hostname end raise(NoProcessFound, "No sidekiq process found for hostname: #{hostname}") unless found_process end |