Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Shutdown gracefull on SIGTERM. Fixes #53

  • Loading branch information...
commit 576bea6a7cd1dda2221180c19682870856609d9c 1 parent c9f616e
@evanphx evanphx authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/puma/cli.rb
View
14 lib/puma/cli.rb
@@ -266,6 +266,12 @@ def parse_options
@temp_status_path = @options[:control_path_temp]
end
+ def graceful_stop(server)
+ log " - Gracefully stopping, waiting for requests to finish"
+ server.stop(true)
+ log " - Goodbye!"
+ end
+
# Parse the options, load the rackup, start the server and wait
# for it to finish.
#
@@ -412,14 +418,16 @@ def run
server.begin_restart
end
+ Signal.trap "SIGTERM" do
+ graceful_stop server
+ end
+
log "Use Ctrl-C to stop"
begin
server.run.join
rescue Interrupt
- log " - Gracefully stopping, waiting for requests to finish"
- server.stop(true)
- log " - Goodbye!"
+ graceful_stop server
end
File.unlink @temp_status_path if @temp_status_path
Please sign in to comment.
Something went wrong with that request. Please try again.