about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-11-05 21:47:42 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-05 21:47:42 +0000
commita78a1addefbc53ac0331f673cef0cceaced83bc4 (patch)
treed8a939576c4bbd6e885a088f631a77b6cd6fcb39
parentc5a4d67091bd4cb1f79157ac1dc0b7dcef869796 (diff)
downloadyahns-a78a1addefbc53ac0331f673cef0cceaced83bc4.tar.gz
It may be disconcerting to not know how long it takes a server
to gracefully exit, so provide that feedback.  While we're at
it, avoid dropping acceptors if we want a forceful exit.
-rw-r--r--lib/yahns/server.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb
index 9eb5378..2b0af03 100644
--- a/lib/yahns/server.rb
+++ b/lib/yahns/server.rb
@@ -378,9 +378,16 @@ class Yahns::Server # :nodoc:
   end
 
   def quit_enter(alive)
-    @logger.info "#{alive ? "grace" : "force"}fully exiting"
+    if alive
+      @logger.info("gracefully exiting shutdown_timeout=#{@shutdown_timeout} s")
+    else # drop connections immediately if signaled twice
+      @logger.info("graceful exit aborted, exiting immediately")
+      # we will still call any app-defined at_exit hooks here
+      # use SIGKILL if you don't want that.
+      exit(0)
+    end
+
     drop_acceptors # stop acceptors, we close epolls in quit_done
-    exit(0) unless alive # drop connections immediately if signaled twice
     @config.config_listeners.each_value do |opts|
       list= opts[:yahns_app_ctx_list] or next
       # Yahns::HttpContext#persistent_connections=