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 "minitest" # License: Ruby
|
||||||
gem "rack" # License: MIT
|
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 "sinatra" # License: MIT-style
|
||||||
gem "haml" # License: MIT
|
gem "haml" # License: MIT
|
||||||
gem "sass" # License: MIT
|
gem "sass" # License: MIT
|
||||||
|
|
|
@ -73,7 +73,7 @@ class LogStash::Test
|
||||||
check_lib("statsd", "statsd-ruby", :optional, "required for statsd output"),
|
check_lib("statsd", "statsd-ruby", :optional, "required for statsd output"),
|
||||||
|
|
||||||
# logstash web
|
# 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("rack", "rack", :required, "needed for logstash web"),
|
||||||
check_lib("sinatra", "sinatra", :required, "needed for logstash web"),
|
check_lib("sinatra", "sinatra", :required, "needed for logstash web"),
|
||||||
check_lib("sass", "sass", :required, "needed for logstash web"),
|
check_lib("sass", "sass", :required, "needed for logstash web"),
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
require "sinatra/base"
|
require "sinatra/base"
|
||||||
|
|
||||||
class LogStash::Web::Server < Sinatra::Base
|
class LogStash::Web::Server < Sinatra::Base
|
||||||
# Mizuno can't serve static files from a jar
|
get '/js/*' do static_file end
|
||||||
# https://github.com/matadon/mizuno/issues/9
|
get '/css/*' do static_file end
|
||||||
#if __FILE__ =~ /^file:.+!.+$/
|
get '/media/*' do static_file end
|
||||||
get '/js/*' do static_file end
|
get '/ws/*' do static_file end
|
||||||
get '/css/*' do static_file end
|
## If here, we aren't running from a jar; safe to serve files
|
||||||
get '/media/*' do static_file end
|
## through the normal public handler.
|
||||||
get '/ws/*' do static_file end
|
#set :public, "#{File.dirname(__FILE__)}/public"
|
||||||
#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
|
|
||||||
|
|
||||||
def static_file
|
def static_file
|
||||||
# request.path_info is the full path of the request.
|
# request.path_info is the full path of the request.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
require "logstash/namespace"
|
require "logstash/namespace"
|
||||||
require "mizuno" # gem mizuno
|
require "ftw" # gem ftw
|
||||||
|
require "rack/handler/ftw" # gem ftw
|
||||||
|
|
||||||
class LogStash::Web::Runner
|
class LogStash::Web::Runner
|
||||||
Settings = Struct.new(:logfile, :address, :port,
|
Settings = Struct.new(:logfile, :address, :port, :backend_url, :bind_host)
|
||||||
:backend_url, :bind_host)
|
|
||||||
|
|
||||||
public
|
public
|
||||||
def run(args)
|
def run(args)
|
||||||
|
@ -59,12 +59,13 @@ class LogStash::Web::Runner
|
||||||
STDOUT.reopen(logfile)
|
STDOUT.reopen(logfile)
|
||||||
STDERR.reopen(logfile)
|
STDERR.reopen(logfile)
|
||||||
end
|
end
|
||||||
|
Cabin::Channel.get.subscribe(STDOUT)
|
||||||
|
|
||||||
@thread = Thread.new do
|
@thread = Thread.new do
|
||||||
Mizuno::HttpServer.run(
|
Cabin::Channel.get.info("Starting web server", :settings => settings)
|
||||||
LogStash::Web::Server.new(settings),
|
Rack::Handler::FTW.run(LogStash::Web::Server.new(settings),
|
||||||
:port => settings.port,
|
:Host => settings.address,
|
||||||
:host => settings.address)
|
:Port => settings.port)
|
||||||
end
|
end
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
#!/usr/bin/env ruby
|
#!/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("%s/../lib" % File.dirname(__FILE__))
|
||||||
$:.unshift(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/controllers/static_files"
|
||||||
require "logstash/web/helpers/require_param"
|
require "logstash/web/helpers/require_param"
|
||||||
require "optparse"
|
require "optparse"
|
||||||
|
require "cabin" # gem cabin
|
||||||
require "rack" # gem rack
|
require "rack" # gem rack
|
||||||
require "sinatra/base" # gem sinatra
|
require "sinatra/base" # gem sinatra
|
||||||
require "haml"
|
require "haml"
|
||||||
|
@ -24,6 +21,12 @@ require "sass"
|
||||||
Encoding.default_external = Encoding::UTF_8
|
Encoding.default_external = Encoding::UTF_8
|
||||||
Encoding.default_internal = 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
|
class LogStash::Web::Server < Sinatra::Base
|
||||||
|
|
||||||
mime_type :html, "text/html"
|
mime_type :html, "text/html"
|
||||||
|
@ -61,6 +64,8 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
|
|
||||||
def initialize(settings)
|
def initialize(settings)
|
||||||
super()
|
super()
|
||||||
|
logger = Cabin::Channel.get
|
||||||
|
logger.info("settings", :settings => settings)
|
||||||
|
|
||||||
# TODO(sissel): Make this better.
|
# TODO(sissel): Make this better.
|
||||||
backend_url = URI.parse(settings.backend_url)
|
backend_url = URI.parse(settings.backend_url)
|
||||||
|
@ -96,6 +101,7 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
:port => backend_url.port
|
:port => backend_url.port
|
||||||
)
|
)
|
||||||
end # backend_url.scheme
|
end # backend_url.scheme
|
||||||
|
logger.info("init done")
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/style.css' do
|
get '/style.css' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue