From 18c4ade90959d4eaa0048e83f3ce1052fa8a5905 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 28 May 2009 10:45:32 -0700 Subject: SIGHUP reloads app even if preload_app is true This makes SIGHUP handling more consistent across different configurations, and allows togging preload_app to take effect when SIGHUP is issued. --- SIGNALS | 4 +--- lib/unicorn.rb | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SIGNALS b/SIGNALS index 01b284e..4aacd7d 100644 --- a/SIGNALS +++ b/SIGNALS @@ -6,9 +6,7 @@ processes are documented here as well. === Master Process -* HUP - reload config file and gracefully restart all workers - If "preload_app" is false (the default), the application code - will be reloaded when workers are restarted as well. +* HUP - reload config file, app, and gracefully restart all workers * INT/TERM - quick shutdown, kills all workers immediately diff --git a/lib/unicorn.rb b/lib/unicorn.rb index be4b6ca..044fed2 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -72,6 +72,7 @@ module Unicorn @listener_opts = {} @config.commit!(self, :skip => [:listeners, :pid]) @request = HttpRequest.new(@logger) + @orig_app = app end # Runs the thing. Returns self so you can run join on it @@ -458,7 +459,7 @@ module Unicorn worker.tempfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) @after_fork.call(self, worker) # can drop perms @timeout /= 2.0 # halve it for select() - build_app! unless @config[:preload_app] + build_app! unless @preload_app end def reopen_worker_logs(worker_nr) @@ -576,6 +577,8 @@ module Unicorn @config.commit!(self) kill_each_worker(:QUIT) Unicorn::Util.reopen_logs + @app = @orig_app + build_app! if @preload_app logger.info "done reloading config_file=#{@config.config_file}" rescue Object => e logger.error "error reloading config_file=#{@config.config_file}: " \ -- cgit v1.2.3-24-ge0c7