mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
- Add daemonize and logfile flags support to logstash-web.
This commit is contained in:
parent
1317ed187f
commit
a4a4490baf
1 changed files with 34 additions and 1 deletions
|
@ -99,9 +99,42 @@ class LogStash::Web::Server < Sinatra::Base
|
|||
body haml :"search/ajax", :layout => !request.xhr?
|
||||
end # elasticsearch.search
|
||||
end # apost '/search/ajax'
|
||||
|
||||
end # class LogStashWeb
|
||||
|
||||
require "optparse"
|
||||
|
||||
Settings = Struct.new(:daemonize, :logfile)
|
||||
settings = Settings.new
|
||||
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
|
||||
settings.daemonize = true
|
||||
end
|
||||
|
||||
opts.on("-l", "--log FILE", "Log to a given path. Default is stdout.") do |path|
|
||||
settings.logfile = path
|
||||
end
|
||||
end
|
||||
|
||||
opts.parse!
|
||||
|
||||
if settings.daemonize
|
||||
if Process.fork == nil
|
||||
Process.setsid
|
||||
else
|
||||
exit(0)
|
||||
end
|
||||
end
|
||||
|
||||
if settings.logfile
|
||||
logfile = File.open(settings.logfile, "w")
|
||||
STDOUT.reopen(logfile)
|
||||
STDERR.reopen(logfile)
|
||||
end
|
||||
|
||||
Rack::Handler::Thin.run(
|
||||
Rack::CommonLogger.new( \
|
||||
Rack::ShowExceptions.new( \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue