From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: yahns-public@yhbt.net Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E64631FAE7; Fri, 5 Jun 2015 09:11:10 +0000 (UTC) From: Eric Wong To: yahns-public@yhbt.net Cc: Eric Wong Subject: [PATCH] support SIGWINCH even if not daemonized Date: Fri, 5 Jun 2015 09:10:59 +0000 Message-Id: <1433495459-30789-1-git-send-email-e@80x24.org> List-Id: This has no effect for the (default) single process case with no master/worker relationship as that does not support SIGWINCH. Some process managers such as foreman and daemontools rely on yahnsnot 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. This follows unicorn commit a6077391bb62d0b13016084b0eea36b987afe8f0 Thanks to Dan Moore for suggesting it on the unicorn list. --- lib/yahns/server_mp.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/yahns/server_mp.rb b/lib/yahns/server_mp.rb index 2e9da20..9e6ec60 100644 --- a/lib/yahns/server_mp.rb +++ b/lib/yahns/server_mp.rb @@ -103,13 +103,13 @@ module Yahns::ServerMP # :nodoc: when :USR2 # exec binary, stay alive in case something went wrong reexec when :WINCH - if @daemon_pipe + if $stdin.tty? + @logger.info "SIGWINCH ignored because we're not daemonized" + else state = :WINCH @logger.info "gracefully stopping all workers" soft_kill_each_worker("QUIT") @worker_processes = 0 - else - @logger.info "SIGWINCH ignored because we're not daemonized" end when :TTIN state = :respawn unless state == :QUIT -- EW