Module: Tap::Server::Runner
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
Instance Method Summary collapse
- #initialize(config = {}) ⇒ Object
-
#run!(rack_app, handler = rack_handler) ⇒ Object
Runs self as configured, on the specified server, host, and port.
- #running? ⇒ Boolean
-
#stop! ⇒ Object
Stops the server if running (ie a handler is set).
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
16 17 18 |
# File 'lib/tap/server/runner.rb', line 16 def handler @handler end |
Instance Method Details
#initialize(config = {}) ⇒ Object
18 19 20 21 |
# File 'lib/tap/server/runner.rb', line 18 def initialize(config={}) @handler = nil initialize_config(config) end |
#run!(rack_app, handler = rack_handler) ⇒ Object
Runs self as configured, on the specified server, host, and port. Use an INT signal to interrupt.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tap/server/runner.rb', line 29 def run!(rack_app, handler=rack_handler) return self if running? handler.run(rack_app, :Host => host, :Port => port) do |handler_instance| @handler = handler_instance trap(:INT) { stop! } yield if block_given? end self end |
#running? ⇒ Boolean
23 24 25 |
# File 'lib/tap/server/runner.rb', line 23 def running? @handler != nil end |
#stop! ⇒ Object
Stops the server if running (ie a handler is set).
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tap/server/runner.rb', line 42 def stop! if running? # Use thins' hard #stop! if available, otherwise just #stop @handler.respond_to?(:stop!) ? @handler.stop! : @handler.stop @handler = nil yield if block_given? end self end |