mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Switch from mizuno to ftw for web serving
This commit is contained in:
parent
aaa1b8f354
commit
6c9a7f000a
5 changed files with 27 additions and 25 deletions
2
Gemfile
2
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
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue