Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (22 sloc) 623 Bytes
require "bundler"
Bundler.setup :default
require "logger"
require "eventmachine"
require "em-synchrony"
require "rity/new_connection"
require "awesome_print"
address, port = "127.0.0.1", 3000
app = proc {|env|
[200, {"Content-Type" => "text/html"}, ["You requested: #{env["REQUEST_URI"]}"]]
}
log = Logger.new($stderr)
log.formatter = proc do |severity, time, progname, message|
"[#{time}] #{severity}: #{message}\n"
end
log.info("Binding to #{address}:#{port}")
EM.synchrony do
trap("INT") { EM.stop }
trap("TERM") { EM.stop }
EM.epoll
EM.start_server address, port, Rity::Connection, app, log
end