Class: Sidekiq::MemoryGuardShutdown
- Inherits:
-
Object
- Object
- Sidekiq::MemoryGuardShutdown
- Defined in:
- lib/sidekiq/memory_guard_shutdown.rb
Overview
Quiets, drains, stops, and finally terminates one Sidekiq process after the
memory guard has claimed restart ownership. The caller runs this object on
Sidekiq's safe thread so completed jobs can return immediately.
Instance Method Summary collapse
- #call ⇒ void
-
#initialize(settings:, telemetry:, identity:) ⇒ MemoryGuardShutdown
constructor
A new instance of MemoryGuardShutdown.
Constructor Details
#initialize(settings:, telemetry:, identity:) ⇒ MemoryGuardShutdown
Returns a new instance of MemoryGuardShutdown.
13 14 15 16 17 |
# File 'lib/sidekiq/memory_guard_shutdown.rb', line 13 def initialize(settings:, telemetry:, identity:) @settings = settings @telemetry = telemetry @identity = identity end |
Instance Method Details
#call ⇒ void
This method returns an undefined value.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sidekiq/memory_guard_shutdown.rb', line 20 def call drained = false begin quiet drained = drain stop(drained:) ensure # Once a restart is claimed, failing halfway through the Redis-backed # quiet/drain/stop sequence must not leave a permanently quiet process. # The container restart policy plus super_fetch are the final safety # net, so always terminate this process even when an earlier phase # raises. terminate(drained:) end end |