diff --git a/fluentd.gemspec b/fluentd.gemspec index 83c5abc18d..0274f22136 100644 --- a/fluentd.gemspec +++ b/fluentd.gemspec @@ -52,6 +52,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency("test-unit", ["~> 3.3"]) gem.add_development_dependency("test-unit-rr", ["~> 1.0"]) gem.add_development_dependency("oj", [">= 2.14", "< 4"]) - gem.add_development_dependency("async", "~> 1.23") gem.add_development_dependency("async-http", ">= 0.50.0") end diff --git a/lib/fluent/plugin_helper/http_server/server.rb b/lib/fluent/plugin_helper/http_server/server.rb index 4266bc639f..d1af7192c3 100644 --- a/lib/fluent/plugin_helper/http_server/server.rb +++ b/lib/fluent/plugin_helper/http_server/server.rb @@ -38,7 +38,8 @@ def initialize(addr:, port:, logger:, default_app: nil, tls_context: nil) scheme = tls_context ? 'https' : 'http' @uri = URI("#{scheme}://#{@addr}:#{@port}").to_s @router = Router.new(default_app) - @reactor = Async::Reactor.new(nil, logger: @logger) + @server_task = nil + Console.logger = @logger opts = if tls_context { ssl_context: tls_context } @@ -54,23 +55,24 @@ def initialize(addr:, port:, logger:, default_app: nil, tls_context: nil) def start(notify = nil) @logger.debug("Start async HTTP server listening #{@uri}") - task = @reactor.run do - @server.run + Async do |task| + @server_task = task.async do + @server.run + end if notify notify.push(:ready) end end - task.stop @logger.debug('Finished HTTP server') end def stop @logger.debug('closing HTTP server') - if @reactor - @reactor.stop + if @server_task + @server_task.stop end end diff --git a/test/plugin_helper/test_http_server_helper.rb b/test/plugin_helper/test_http_server_helper.rb index 6691c9182d..27cc3d32d5 100644 --- a/test/plugin_helper/test_http_server_helper.rb +++ b/test/plugin_helper/test_http_server_helper.rb @@ -127,12 +127,12 @@ def start_https_request(addr, port, verify: true, cert_path: nil, selfsigned: tr end client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse("https://#{addr}:#{port}", ssl_context: context)) - reactor = Async::Reactor.new(nil, logger: NULL_LOGGER) + Console.logger = NULL_LOGGER resp = nil error = nil - reactor.run do + Async do |task| begin response = yield(client) rescue => e # Async::Reactor rescue all error. handle it by myself