yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] support SIGWINCH even if not daemonized
Date: Fri,  5 Jun 2015 09:10:59 +0000	[thread overview]
Message-ID: <1433495459-30789-1-git-send-email-e@80x24.org> (raw)

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


             reply	other threads:[~2015-06-05  9:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-05  9:10 Eric Wong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-06-05  9:01 [PATCH] support SIGWINCH even if not daemonized Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433495459-30789-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=yahns-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).