add ability to enable/disable logging
This commit is contained in:
parent
91ad5de7d1
commit
936372cb57
@ -8,12 +8,18 @@ module Flowerbox
|
|||||||
attr_reader :options
|
attr_reader :options
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@options = options || {}
|
@options = { :logging => false }.merge(options || {})
|
||||||
end
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
@server_thread = Thread.new do
|
@server_thread = Thread.new do
|
||||||
::Rack::Handler::WEBrick.run(options[:app], :Port => port, :Host => interface) do |server|
|
server_options = { :Port => port, :Host => interface }
|
||||||
|
if !options[:logging]
|
||||||
|
server_options[:AccessLog] = [ nil, nil ]
|
||||||
|
server_options[:Logger] = Logger.new('/dev/null')
|
||||||
|
end
|
||||||
|
|
||||||
|
::Rack::Handler::WEBrick.run(options[:app], server_options) do |server|
|
||||||
trap('QUIT') { server.stop }
|
trap('QUIT') { server.stop }
|
||||||
|
|
||||||
Thread.current[:server] = server
|
Thread.current[:server] = server
|
||||||
@ -21,8 +27,6 @@ module Flowerbox
|
|||||||
end
|
end
|
||||||
|
|
||||||
while !@server_thread[:server] && @server_thread.alive?
|
while !@server_thread[:server] && @server_thread.alive?
|
||||||
$stderr.puts "waiting"
|
|
||||||
|
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user