Class: Launch::WEBrickHTTPServer

Inherits:
WEBrick::HTTPServer
  • Object
show all
Defined in:
lib/launch/webrick.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WEBrickHTTPServer

Initializes an HTTP server with options and set the server’s listeners using Launch. A TERM handler to shut down the server is automatically set.

:LaunchdSockets may be set to change the socket key from the default of 'WEBrickSockets'



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/launch/webrick.rb', line 59

def initialize(options = {})
  options[:DoNotListen] = true
  sockets_key = options.delete(:LaunchdSockets) || 'WEBrickSockets'

  super

  @job = Launch::Job.checkin
  sockets = @job.sockets[sockets_key]
  listeners.replace(socket)

  trap("TERM") { shutdown }
end