Skip to content

Commit

Permalink
Split ForceShutdown and Exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zanker-stripe committed Mar 30, 2020
1 parent f0fe6c3 commit 948f17e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/puma/server.rb
Expand Up @@ -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
Expand Down

0 comments on commit 948f17e

Please sign in to comment.