unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* at_exit ignored on worker processes
@ 2022-04-11 19:02 pudiva chip líquida
  2022-04-11 20:42 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: pudiva chip líquida @ 2022-04-11 19:02 UTC (permalink / raw)
  To: unicorn-public

Dear unicorns,

I was trying to register some code with `at_exit`, so that it would
execute when my app processes terminated, but I found out that it was
being run only for the main unicorn process, not the workers, as those
are terminated with `exit!` (note the !):

https://yhbt.net/unicorn.git/tree/lib/unicorn/http_server.rb?h=v6.0.0#n675

Would you mind me asking why you decided to go with `exit!` instead of
plain `exit`, and what would be the correct way of executing code on
worker termination?

Thank you!
Best regards,

-- 
pudiva chip líquida

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

* Re: at_exit ignored on worker processes
  2022-04-11 19:02 at_exit ignored on worker processes pudiva chip líquida
@ 2022-04-11 20:42 ` Eric Wong
  2022-04-12  0:27   ` pudiva chip líquida
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2022-04-11 20:42 UTC (permalink / raw)
  To: pudiva chip líquida; +Cc: unicorn-public

pudiva chip líquida <pudiva@skylittlesystem.org> wrote:
> Dear unicorns,
> 
> I was trying to register some code with `at_exit`, so that it would
> execute when my app processes terminated, but I found out that it was
> being run only for the main unicorn process, not the workers, as those
> are terminated with `exit!` (note the !):
> 
> https://yhbt.net/unicorn.git/tree/lib/unicorn/http_server.rb?h=v6.0.0#n675
> 
> Would you mind me asking why you decided to go with `exit!` instead of
> plain `exit`, and what would be the correct way of executing code on
> worker termination?

That `exit!' is only temporary during worker init on SIGQUIT.

:QUIT is retrapped and made graceful at the end of init_worker_process:

  https://yhbt.net/unicorn.git/tree/lib/unicorn/http_server.rb?h=v6.0.0#n694

t/t0020-at_exit-handler.sh should be testing SIGQUIT behavior

SIGTERM/SIGINT remain `exit!' since they're specified as immediate
(well, as soon as Ruby sig handlers fire)

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

* Re: at_exit ignored on worker processes
  2022-04-11 20:42 ` Eric Wong
@ 2022-04-12  0:27   ` pudiva chip líquida
  0 siblings, 0 replies; 3+ messages in thread
From: pudiva chip líquida @ 2022-04-12  0:27 UTC (permalink / raw)
  To: Eric Wong; +Cc: unicorn-public

> That `exit!' is only temporary during worker init on SIGQUIT.
>
> :QUIT is retrapped and made graceful at the end of init_worker_process:
>
>   https://yhbt.net/unicorn.git/tree/lib/unicorn/http_server.rb?h=v6.0.0#n694
>
> t/t0020-at_exit-handler.sh should be testing SIGQUIT behavior
>
> SIGTERM/SIGINT remain `exit!' since they're specified as immediate
> (well, as soon as Ruby sig handlers fire)

Ahhhh I see! Thank you!

-- 
pudia chip líquida

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

end of thread, other threads:[~2022-04-12  0:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 19:02 at_exit ignored on worker processes pudiva chip líquida
2022-04-11 20:42 ` Eric Wong
2022-04-12  0:27   ` pudiva chip líquida

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.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).