Module: RailsPodKit::Shutdown
- Defined in:
- lib/rails_pod_kit/shutdown.rb
Overview
Blocks the main thread of an always-on entry point until the orchestrator signals. A self-pipe rather than a Queue or a Mutex: writing to an IO is one of the few things safe to do from a trap handler.
Constant Summary collapse
- SIGNALS =
%w[INT TERM].freeze
Class Method Summary collapse
Class Method Details
.await(signals: SIGNALS) ⇒ Object
12 13 14 15 16 |
# File 'lib/rails_pod_kit/shutdown.rb', line 12 def await(signals: SIGNALS) reader, writer = IO.pipe signals.each { |signal| Signal.trap(signal) { writer.puts(signal) } } reader.gets end |