Class: GoodJob::ProbeServer::WebrickHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/good_job/probe_server/webrick_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ WebrickHandler

Returns a new instance of WebrickHandler.



6
7
8
9
10
11
# File 'lib/good_job/probe_server/webrick_handler.rb', line 6

def initialize(app, options = {})
  @app    = app
  @port   = options[:port]
  @logger = options[:logger]
  @handler = ::Rack::Handler.get('webrick')
end

Instance Method Details

#build_futureObject



21
22
23
24
25
# File 'lib/good_job/probe_server/webrick_handler.rb', line 21

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/good_job/probe_server/webrick_handler.rb', line 17

def running?
  @handler&.instance_variable_get(:@server)&.status == :Running
end

#stopObject



13
14
15
# File 'lib/good_job/probe_server/webrick_handler.rb', line 13

def stop
  @handler&.shutdown
end