unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
* SIGWINCH with Forego/Heroku Local
@ 2016-12-08 17:01 Josh Morrow
  2016-12-08 18:40 ` Eric Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Morrow @ 2016-12-08 17:01 UTC (permalink / raw)
  To: unicorn-public

Hello!

 I've recently been using unicorn in my rails development environment,
and it's been almost entirely great so far. I do have one question
about how to address an issue: `WINCH` signals coming from my
terminal. I run with the `heroku local` command, which runs
https://github.com/ddollar/forego under the hood. Forego does not
identify STDIN as a tty (because it's not really). This means that
whenever I resize my terminal Unicorn attempts to stop all workers as
per https://github.com/defunkt/unicorn/blob/3dbbda30f02a40025abdee395fb0803985046db6/lib/unicorn/http_server.rb#L297-L305.
What is the correct way to fix this issue? Should something in Unicorn
change? (perhaps we use some other criteria than stdin?)

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SIGWINCH with Forego/Heroku Local
  2016-12-08 17:01 SIGWINCH with Forego/Heroku Local Josh Morrow
@ 2016-12-08 18:40 ` Eric Wong
       [not found]   ` <CAHdu2E6=qv1gmLGbZfrivhX5vVYgMq7cwOpCZ9yvFGTR17Prfw@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2016-12-08 18:40 UTC (permalink / raw)
  To: Josh Morrow; +Cc: unicorn-public

Josh Morrow <jcmorrow@thoughtbot.com> wrote:
> Hello!
> 
>  I've recently been using unicorn in my rails development environment,
> and it's been almost entirely great so far. I do have one question
> about how to address an issue: `WINCH` signals coming from my
> terminal. I run with the `heroku local` command, which runs
> https://github.com/ddollar/forego under the hood. Forego does not
> identify STDIN as a tty (because it's not really). This means that
> whenever I resize my terminal Unicorn attempts to stop all workers as
> per https://github.com/defunkt/unicorn/blob/3dbbda30f02a40025abdee395fb0803985046db6/lib/unicorn/http_server.rb#L297-L305.
> What is the correct way to fix this issue? Should something in Unicorn
> change? (perhaps we use some other criteria than stdin?)

Resetting the SIGWINCH handler to the default in the before_fork
handler will work:

	before_fork do |server, worker|
	  # runs in the master
	  trap(:WINCH, 'DEFAULT')
	end


Fwiw, we switched to checking stdin last year so SIGWINCH could
be usable with foreman and other process managers:

https://bogomips.org/unicorn-public/etPan.555b4293.5b47a5b7.e617@danbookpro/T/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SIGWINCH with Forego/Heroku Local
       [not found]   ` <CAHdu2E6=qv1gmLGbZfrivhX5vVYgMq7cwOpCZ9yvFGTR17Prfw@mail.gmail.com>
@ 2016-12-09  1:55     ` Eric Wong
  2016-12-09 17:01       ` Josh Morrow
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2016-12-09  1:55 UTC (permalink / raw)
  To: Josh Morrow; +Cc: unicorn-public

(please don't drop the public list/archive address from the Cc:)

Josh Morrow <jcmorrow@thoughtbot.com> wrote:
> Eric Wong <e@80x24.org> wrote:
> > Fwiw, we switched to checking stdin last year so SIGWINCH could
> > be usable with foreman and other process managers:
> 
> In foreman `$stdin.tty?` returns `true`. In ForeGO it returns `nil` : (.

`nil` or `false`?  With how unicorn uses it, it doesn't matter,
but it should really be `false` there based on reading the
rb_io_isatty function in io.c of the MRI source.

But anyways, I suspect ForeGO redirects the stdin to /dev/null
(you can check with lsof); which is totally reasonable for
running daemons.

That is why I recommended the before_fork workaround to
trap(:WINCH, "DEFAULT") to restore the default noop behavior.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SIGWINCH with Forego/Heroku Local
  2016-12-09  1:55     ` Eric Wong
@ 2016-12-09 17:01       ` Josh Morrow
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Morrow @ 2016-12-09 17:01 UTC (permalink / raw)
  To: Eric Wong; +Cc: unicorn-public

> (please don't drop the public list/archive address from the Cc:)

Whoops, sorry, my bad.

On Thu, Dec 8, 2016 at 5:55 PM, Eric Wong <e@80x24.org> wrote:
> (please don't drop the public list/archive address from the Cc:)
>
> Josh Morrow <jcmorrow@thoughtbot.com> wrote:
>> Eric Wong <e@80x24.org> wrote:
>> > Fwiw, we switched to checking stdin last year so SIGWINCH could
>> > be usable with foreman and other process managers:
>>
>> In foreman `$stdin.tty?` returns `true`. In ForeGO it returns `nil` : (.
>
> `nil` or `false`?  With how unicorn uses it, it doesn't matter,
> but it should really be `false` there based on reading the
> rb_io_isatty function in io.c of the MRI source.
>
> But anyways, I suspect ForeGO redirects the stdin to /dev/null
> (you can check with lsof); which is totally reasonable for
> running daemons.
>
> That is why I recommended the before_fork workaround to
> trap(:WINCH, "DEFAULT") to restore the default noop behavior.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-08 17:01 SIGWINCH with Forego/Heroku Local Josh Morrow
2016-12-08 18:40 ` Eric Wong
     [not found]   ` <CAHdu2E6=qv1gmLGbZfrivhX5vVYgMq7cwOpCZ9yvFGTR17Prfw@mail.gmail.com>
2016-12-09  1:55     ` Eric Wong
2016-12-09 17:01       ` Josh Morrow

unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox