summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nickserver/daemon.rb1
-rw-r--r--lib/nickserver/reel_server.rb14
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/nickserver/daemon.rb b/lib/nickserver/daemon.rb
index 9cc1af7..0f9e7bf 100644
--- a/lib/nickserver/daemon.rb
+++ b/lib/nickserver/daemon.rb
@@ -176,6 +176,7 @@ module Nickserver
$stdout.reopen(log_path, 'a')
$stderr.reopen $stdout
$stdout.sync = true
+ $stderr.sync = true
else
# redirect to /dev/null
$stdin.reopen '/dev/null'
diff --git a/lib/nickserver/reel_server.rb b/lib/nickserver/reel_server.rb
index d2a95ba..9a7053b 100644
--- a/lib/nickserver/reel_server.rb
+++ b/lib/nickserver/reel_server.rb
@@ -23,14 +23,24 @@ module Nickserver
def on_connection(connection)
connection.each_request do |request|
- handler = handler_for(request)
- handler.respond_to params(request), request.headers
+ handle_request(request)
end
end
protected
+ def handle_request(request)
+ puts "#{request.method} #{request.uri}"
+ puts " #{params(request)}"
+ handler = handler_for(request)
+ handler.respond_to params(request), request.headers
+ rescue StandardError => e
+ puts e
+ puts e.backtrace.join "\n "
+ request.respond 500, "{}"
+ end
+
def handler_for(request)
# with reel the request is the responder
Dispatcher.new(request)