Class: Fluent::PluginHelper::HttpServer::Compat::Server
- Inherits:
-
Object
- Object
- Fluent::PluginHelper::HttpServer::Compat::Server
- Defined in:
- lib/fluent/plugin_helper/http_server/compat/server.rb
Instance Method Summary collapse
-
#initialize(addr:, port:, logger:, default_app: nil, tls_context: nil) ⇒ Server
constructor
A new instance of Server.
- #start(notify = nil) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(addr:, port:, logger:, default_app: nil, tls_context: nil) ⇒ Server
Returns a new instance of Server.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fluent/plugin_helper/http_server/compat/server.rb', line 29 def initialize(addr:, port:, logger:, default_app: nil, tls_context: nil) @addr = addr @port = port @logger = logger config = { BindAddress: @addr, Port: @port, Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL), AccessLog: [], } if tls_context require 'webrick/https' @logger.warn('Webrick ignores given TLS version') tls_opt = Fluent::PluginHelper::HttpServer::Compat::SSLContextExtractor.extract(tls_context) config = tls_opt.merge(**config) end @server = WEBrick::HTTPServer.new(config) # @example ["/example.json", :get, handler object] @methods = [] if block_given? yield(self) end end |
Instance Method Details
#start(notify = nil) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/fluent/plugin_helper/http_server/compat/server.rb', line 57 def start(notify = nil) build_handler notify.push(:ready) @logger.debug('Start webrick HTTP server listening') @server.start end |
#stop ⇒ Object
64 65 66 67 |
# File 'lib/fluent/plugin_helper/http_server/compat/server.rb', line 64 def stop @server.shutdown @server.stop end |