From a6077391bb62d0b13016084b0eea36b987afe8f0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 20 May 2015 22:15:48 +0000 Subject: process SIGWINCH unless stdin is a TTY Some process managers such as foreman and daemontools rely on unicorn not daemonizing, but we still want to be able to process SIGWINCH in that case. stdout and stderr may be redirected to a pipe (for cronolog or similar process), so those are less likely to be attached to a TTY than stdin. This also allows users to process SIGWINCH when running inside a regular terminal if they redirect stdin to /dev/null. Reported-by: Dan Moore References: <20150519232858.GA23515@dcvr.yhbt.net> --- lib/unicorn/http_server.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 82747b8..cf8e122 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -294,13 +294,13 @@ class Unicorn::HttpServer when :USR2 # exec binary, stay alive in case something went wrong reexec when :WINCH - if Unicorn::Configurator::RACKUP[:daemonized] + if $stdin.tty? + logger.info "SIGWINCH ignored because we're not daemonized" + else respawn = false logger.info "gracefully stopping all workers" soft_kill_each_worker(:QUIT) self.worker_processes = 0 - else - logger.info "SIGWINCH ignored because we're not daemonized" end when :TTIN respawn = true -- cgit v1.2.3-24-ge0c7