module Poisol::Server
Public Instance Methods
access_log()
click to toggle source
# File lib/poisol/server.rb, line 46 def access_log log_file = File.open 'log/poisol_webrick.log', 'a+' [ [log_file, "#{WEBrick::AccessLog::COMBINED_LOG_FORMAT} %T"], ] end
attach_request_handling()
click to toggle source
# File lib/poisol/server.rb, line 32 def attach_request_handling @server.mount '/', ExtendedServer end
attach_shutdown()
click to toggle source
# File lib/poisol/server.rb, line 36 def attach_shutdown trap 'INT' do @server.shutdown end end
base_url()
click to toggle source
# File lib/poisol/server.rb, line 28 def base_url "http://localhost:#{@port}" end
log()
click to toggle source
# File lib/poisol/server.rb, line 40 def log FileUtils.mkdir_p "log" unless File.exists?("log") log_file = File.open 'log/poisol_webrick.log', 'a+' WEBrick::Log.new log_file end
start(port)
click to toggle source
# File lib/poisol/server.rb, line 18 def start port PoisolLog.info "Starting server... as http://localhost:#{port}" @server = WEBrick::HTTPServer.new :Port => port, :Logger => log, :AccessLog => access_log @port = port attach_shutdown attach_request_handling Thread.new{@server.start} PoisolLog.info "Server Started at http://localhost:#{port}" end
stop()
click to toggle source
# File lib/poisol/server.rb, line 53 def stop if @server.present? @server.shutdown PoisolLog.info "Server is shutdown" end end