Sha256: 95b376070a604a14fce8312c10212bec71278a4f4729f9b7988c15d8b47c84ef

Contents?: true

Size: 544 Bytes

Versions: 5

Compression:

Stored size: 544 Bytes

Contents

# Traps all {the signals NAMES} that should be intercepted by a long-running background process.
module CarrotRpc::ServerRunner::Signals
  # CONSTANTS

  # The name of the signals to trap.
  NAMES = %w(HUP INT QUIT TERM).freeze

  # Traps all {NAMES}.
  #
  # @yield [name] Block to call when the signal is trapped.
  # @yieldparam name [String] the name of the signal that was trapped
  # @yieldreturn [void]
  # @return [void]
  def self.trap
    NAMES.each do |name|
      Kernel.trap(name) do
        yield name
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
carrot_rpc-0.4.1 lib/carrot_rpc/server_runner/signals.rb
carrot_rpc-0.4.0 lib/carrot_rpc/server_runner/signals.rb
carrot_rpc-0.3.0 lib/carrot_rpc/server_runner/signals.rb
carrot_rpc-0.2.3 lib/carrot_rpc/server_runner/signals.rb
carrot_rpc-0.2.3.pre lib/carrot_rpc/server_runner/signals.rb