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 # '/'
|
||||
|
||||
aget '/search' do
|
||||
result_callback = proc do
|
||||
result_callback = proc do
|
||||
status 500 if @error
|
||||
|
||||
params[:format] ||= "html"
|
||||
|
@ -104,7 +104,7 @@ class LogStash::Web::Server < Sinatra::Base
|
|||
if count and offset
|
||||
if @total > (count + offset)
|
||||
@result_end = (count + offset)
|
||||
else
|
||||
else
|
||||
@result_end = @total
|
||||
end
|
||||
@result_start = offset
|
||||
|
@ -137,27 +137,39 @@ class LogStash::Web::Server < Sinatra::Base
|
|||
end # class LogStash::Web::Server
|
||||
|
||||
require "optparse"
|
||||
Settings = Struct.new(:daemonize, :logfile)
|
||||
Settings = Struct.new(:daemonize, :logfile, :host, :port)
|
||||
settings = Settings.new
|
||||
|
||||
settings.host = "0.0.0.0"
|
||||
settings.port = 9292
|
||||
|
||||
progname = File.basename($0)
|
||||
|
||||
opts = OptionParser.new do |opts|
|
||||
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
|
||||
end
|
||||
|
||||
opts.on("-l", "--log FILE", "Log to a given path. Default is stdout.") do |path|
|
||||
settings.logfile = path
|
||||
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
|
||||
|
||||
opts.parse!
|
||||
|
||||
if settings.daemonize
|
||||
if Process.fork == nil
|
||||
Process.setsid
|
||||
Process.setsid
|
||||
else
|
||||
exit(0)
|
||||
end
|
||||
|
@ -168,7 +180,7 @@ if settings.logfile
|
|||
STDOUT.reopen(logfile)
|
||||
STDERR.reopen(logfile)
|
||||
elsif settings.daemonize
|
||||
# Write to /dev/null if
|
||||
# Write to /dev/null if
|
||||
devnull = File.open("/dev/null", "w")
|
||||
STDOUT.reopen(devnull)
|
||||
STDERR.reopen(devnull)
|
||||
|
@ -178,4 +190,4 @@ Rack::Handler::Thin.run(
|
|||
Rack::CommonLogger.new( \
|
||||
Rack::ShowExceptions.new( \
|
||||
LogStash::Web::Server.new)),
|
||||
:Port => 9292)
|
||||
:Port => settings.port, :Host => settings.host)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue