diff --git a/Gemfile b/Gemfile index fdbd1b518..47d307241 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem "jruby-openssl", :platforms => :jruby # For enabling SSL support, CPL/GPL 2. gem "minitest" # License: Ruby gem "rack" # License: MIT -gem "mizuno", :platforms => :jruby # License: Apache 2.0 +gem "ftw", "~> 0.0.11" # License: Apache 2.0 gem "sinatra" # License: MIT-style gem "haml" # License: MIT gem "sass" # License: MIT diff --git a/lib/logstash/test.rb b/lib/logstash/test.rb index 2bdfb20fc..547d890b8 100644 --- a/lib/logstash/test.rb +++ b/lib/logstash/test.rb @@ -73,7 +73,7 @@ class LogStash::Test check_lib("statsd", "statsd-ruby", :optional, "required for statsd output"), # logstash web - check_lib("mizuno", "mizuno", :required, "needed for logstash web"), + check_lib("ftw", "ftw", :required, "needed for logstash web"), check_lib("rack", "rack", :required, "needed for logstash web"), check_lib("sinatra", "sinatra", :required, "needed for logstash web"), check_lib("sass", "sass", :required, "needed for logstash web"), diff --git a/lib/logstash/web/controllers/static_files.rb b/lib/logstash/web/controllers/static_files.rb index 94b32d149..7b37b05f9 100644 --- a/lib/logstash/web/controllers/static_files.rb +++ b/lib/logstash/web/controllers/static_files.rb @@ -1,18 +1,13 @@ require "sinatra/base" class LogStash::Web::Server < Sinatra::Base - # Mizuno can't serve static files from a jar - # https://github.com/matadon/mizuno/issues/9 - #if __FILE__ =~ /^file:.+!.+$/ - get '/js/*' do static_file end - get '/css/*' do static_file end - get '/media/*' do static_file end - get '/ws/*' do static_file end - #else - ## If here, we aren't running from a jar; safe to serve files - ## through the normal public handler. - #set :public, "#{File.dirname(__FILE__)}/public" - #end + get '/js/*' do static_file end + get '/css/*' do static_file end + get '/media/*' do static_file end + get '/ws/*' do static_file end + ## If here, we aren't running from a jar; safe to serve files + ## through the normal public handler. + #set :public, "#{File.dirname(__FILE__)}/public" def static_file # request.path_info is the full path of the request. diff --git a/lib/logstash/web/runner.rb b/lib/logstash/web/runner.rb index fc521d9d0..89c23abb1 100644 --- a/lib/logstash/web/runner.rb +++ b/lib/logstash/web/runner.rb @@ -1,9 +1,9 @@ require "logstash/namespace" -require "mizuno" # gem mizuno +require "ftw" # gem ftw +require "rack/handler/ftw" # gem ftw class LogStash::Web::Runner - Settings = Struct.new(:logfile, :address, :port, - :backend_url, :bind_host) + Settings = Struct.new(:logfile, :address, :port, :backend_url, :bind_host) public def run(args) @@ -59,12 +59,13 @@ class LogStash::Web::Runner STDOUT.reopen(logfile) STDERR.reopen(logfile) end + Cabin::Channel.get.subscribe(STDOUT) @thread = Thread.new do - Mizuno::HttpServer.run( - LogStash::Web::Server.new(settings), - :port => settings.port, - :host => settings.address) + Cabin::Channel.get.info("Starting web server", :settings => settings) + Rack::Handler::FTW.run(LogStash::Web::Server.new(settings), + :Host => settings.address, + :Port => settings.port) end return args diff --git a/lib/logstash/web/server.rb b/lib/logstash/web/server.rb index 5e900a45c..186ca3035 100644 --- a/lib/logstash/web/server.rb +++ b/lib/logstash/web/server.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# I don't want folks to have to learn to use yet another tool (rackup) -# just to launch logstash-web. So let's work like a standard ruby -# library. - $:.unshift("%s/../lib" % File.dirname(__FILE__)) $:.unshift(File.dirname(__FILE__)) @@ -16,6 +12,7 @@ require "logstash/web/controllers/search" require "logstash/web/controllers/static_files" require "logstash/web/helpers/require_param" require "optparse" +require "cabin" # gem cabin require "rack" # gem rack require "sinatra/base" # gem sinatra require "haml" @@ -24,6 +21,12 @@ require "sass" Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 +class FTW::Connection + def rewind + # Rack::Request (Or sinatra?) calls #rewind. fake it. + end +end + class LogStash::Web::Server < Sinatra::Base mime_type :html, "text/html" @@ -61,6 +64,8 @@ class LogStash::Web::Server < Sinatra::Base def initialize(settings) super() + logger = Cabin::Channel.get + logger.info("settings", :settings => settings) # TODO(sissel): Make this better. backend_url = URI.parse(settings.backend_url) @@ -96,6 +101,7 @@ class LogStash::Web::Server < Sinatra::Base :port => backend_url.port ) end # backend_url.scheme + logger.info("init done") end get '/style.css' do