Class: GoodJob::ProbeServer::WebrickHandler
- Inherits:
-
Object
- Object
- GoodJob::ProbeServer::WebrickHandler
- Defined in:
- lib/good_job/probe_server/webrick_handler.rb
Instance Method Summary collapse
- #build_future ⇒ Object
-
#initialize(app, options = {}) ⇒ WebrickHandler
constructor
A new instance of WebrickHandler.
- #running? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ WebrickHandler
Returns a new instance of WebrickHandler.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/good_job/probe_server/webrick_handler.rb', line 6 def initialize(app, = {}) @app = app @port = [:port] @logger = [:logger] # Workaround for rack >= 3.1.x as auto-loading of rack/handler was removed. # We should move to rackup in the long run. # See https://github.com/rack/rack/pull/1937. @handler = begin require 'rackup/handler' ::Rackup::Handler.get('webrick') rescue LoadError require "rack/handler" ::Rack::Handler.get('webrick') end end |
Instance Method Details
#build_future ⇒ Object
31 32 33 34 35 |
# File 'lib/good_job/probe_server/webrick_handler.rb', line 31 def build_future Concurrent::Future.new(args: [@handler, @port, GoodJob.logger]) do |thr_handler, thr_port, thr_logger| thr_handler.run(@app, Port: thr_port, Host: '0.0.0.0', Logger: thr_logger, AccessLog: []) end end |
#running? ⇒ Boolean
27 28 29 |
# File 'lib/good_job/probe_server/webrick_handler.rb', line 27 def running? @handler&.instance_variable_get(:@server)&.status == :Running end |
#stop ⇒ Object
23 24 25 |
# File 'lib/good_job/probe_server/webrick_handler.rb', line 23 def stop @handler&.shutdown end |