class ScoutApm::Remote::Server
Attributes
Public Class Methods
Source
# File lib/scout_apm/remote/server.rb, line 11 def initialize(bind, port, router, logger) @router = router @logger = logger @bind = bind @port = port @server = nil end
Public Instance Methods
Source
# File lib/scout_apm/remote/server.rb, line 19 def require_webrick require 'webrick' true rescue LoadError @logger.warn( %q|Could not require Webrick. Ruby 3.0 stopped bundling it automatically, but it is required to instrument Resque. Please add Webrick to your Gemfile.| ) false end
Source
# File lib/scout_apm/remote/server.rb, line 61 def running? @thread.alive? @server && @server.status == :Running end
Source
# File lib/scout_apm/remote/server.rb, line 31 def start return false unless require_webrick @server = WEBrick::HTTPServer.new( :BindAddress => bind, :Port => port, :AccessLog => [], :Logger => @logger ) @server.mount_proc '/' do |request, response| router.handle(request.body) # arbitrary response, client doesn't expect anything in particular response.body = 'Ok' end @thread = Thread.new do begin logger.debug("Remote: Starting Server on #{bind}:#{port}") @server.start logger.debug("Remote: Server returned after #start call, thread exiting") rescue => e logger.debug("Remote: Server Exception, #{e},\n#{e.backtrace.join("\n\t")}") end end end
Source
# File lib/scout_apm/remote/server.rb, line 66 def stop @server.stop @thread.kill end