mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Merge branch 'master' of https://github.com/pusewicz/logstash into pull/9
This commit is contained in:
commit
5fad88ab96
1 changed files with 19 additions and 7 deletions
|
@ -32,7 +32,7 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
end # '/'
|
end # '/'
|
||||||
|
|
||||||
aget '/search' do
|
aget '/search' do
|
||||||
result_callback = proc do
|
result_callback = proc do
|
||||||
status 500 if @error
|
status 500 if @error
|
||||||
|
|
||||||
params[:format] ||= "html"
|
params[:format] ||= "html"
|
||||||
|
@ -104,7 +104,7 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
if count and offset
|
if count and offset
|
||||||
if @total > (count + offset)
|
if @total > (count + offset)
|
||||||
@result_end = (count + offset)
|
@result_end = (count + offset)
|
||||||
else
|
else
|
||||||
@result_end = @total
|
@result_end = @total
|
||||||
end
|
end
|
||||||
@result_start = offset
|
@result_start = offset
|
||||||
|
@ -137,27 +137,39 @@ class LogStash::Web::Server < Sinatra::Base
|
||||||
end # class LogStash::Web::Server
|
end # class LogStash::Web::Server
|
||||||
|
|
||||||
require "optparse"
|
require "optparse"
|
||||||
Settings = Struct.new(:daemonize, :logfile)
|
Settings = Struct.new(:daemonize, :logfile, :host, :port)
|
||||||
settings = Settings.new
|
settings = Settings.new
|
||||||
|
|
||||||
|
settings.host = "0.0.0.0"
|
||||||
|
settings.port = 9292
|
||||||
|
|
||||||
progname = File.basename($0)
|
progname = File.basename($0)
|
||||||
|
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: #{progname} [options]"
|
opts.banner = "Usage: #{progname} [options]"
|
||||||
|
|
||||||
opts.on("-d", "--daemonize", "Daemonize (default is run in foreground)") do
|
opts.on("-d", "--daemonize", "Daemonize (default is run in foreground).") do
|
||||||
settings.daemonize = true
|
settings.daemonize = true
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("-l", "--log FILE", "Log to a given path. Default is stdout.") do |path|
|
opts.on("-l", "--log FILE", "Log to a given path. Default is stdout.") do |path|
|
||||||
settings.logfile = path
|
settings.logfile = path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("-H", "--host HOST", "Host on which to start webserver. Default is 0.0.0.0.") do |host|
|
||||||
|
settings.host = host
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("-p", "--port PORT", "Port on which to start webserver. Default is 9292.") do |port|
|
||||||
|
settings.port = port.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.parse!
|
opts.parse!
|
||||||
|
|
||||||
if settings.daemonize
|
if settings.daemonize
|
||||||
if Process.fork == nil
|
if Process.fork == nil
|
||||||
Process.setsid
|
Process.setsid
|
||||||
else
|
else
|
||||||
exit(0)
|
exit(0)
|
||||||
end
|
end
|
||||||
|
@ -168,7 +180,7 @@ if settings.logfile
|
||||||
STDOUT.reopen(logfile)
|
STDOUT.reopen(logfile)
|
||||||
STDERR.reopen(logfile)
|
STDERR.reopen(logfile)
|
||||||
elsif settings.daemonize
|
elsif settings.daemonize
|
||||||
# Write to /dev/null if
|
# Write to /dev/null if
|
||||||
devnull = File.open("/dev/null", "w")
|
devnull = File.open("/dev/null", "w")
|
||||||
STDOUT.reopen(devnull)
|
STDOUT.reopen(devnull)
|
||||||
STDERR.reopen(devnull)
|
STDERR.reopen(devnull)
|
||||||
|
@ -178,4 +190,4 @@ Rack::Handler::Thin.run(
|
||||||
Rack::CommonLogger.new( \
|
Rack::CommonLogger.new( \
|
||||||
Rack::ShowExceptions.new( \
|
Rack::ShowExceptions.new( \
|
||||||
LogStash::Web::Server.new)),
|
LogStash::Web::Server.new)),
|
||||||
:Port => 9292)
|
:Port => settings.port, :Host => settings.host)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue