From 948f17e618b50540dcfee89f0d22525af0d7cd58 Mon Sep 17 00:00:00 2001 From: Zach Anker Date: Mon, 30 Mar 2020 11:53:41 -0700 Subject: [PATCH] Split ForceShutdown and Exception handling --- lib/puma/server.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 1212dd60b6..0825d0938c 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -589,17 +589,15 @@ def handle_request(req, lines) return :async end - rescue Exception => e + rescue ThreadPool::ForceShutdown => e @events.unknown_error self, e, "Rack app", env + @events.log "Detected force shutdown of a thread" - status = 500 - if e.is_a?(ThreadPool::ForceShutdown) - status = 503 - - @events.log "Detected force shutdown of a thread, returning 503" - end + status, headers, res_body = lowlevel_error(e, env, 503) + rescue Exception => e + @events.unknown_error self, e, "Rack app", env - status, headers, res_body = lowlevel_error(e, env, status) + status, headers, res_body = lowlevel_error(e, env, 500) end content_length = nil