Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
* Waiting for deferred actions to finish
@ 2017-01-09 13:43 alex0375
  2017-01-09 19:43 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: alex0375 @ 2017-01-09 13:43 UTC (permalink / raw)
  To: rainbows-public

Hello!

I would like the Rainbows! to wait for deferred actions to finish
before shutdown. The documentation says the following:

> QUIT - graceful shutdown, waits for workers to finish their current request before finishing. This currently does not wait for requests deferred to a separate thread when using EventMachine (when app.deferred?(env) => true)
>
> https://bogomips.org/rainbows/SIGNALS.html

I came up with the following solution:

after_fork do |_server, _worker|
  # Wait for all deferred actions to finish before killing worker.
  Rainbows.at_quit do
    loop do
      break if EventMachine.defers_finished?

      sleep 1
    end
  end
end

Am I missing something? Can this be a part of Rainbows?

Thanks!

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

end of thread, other threads:[~2017-01-10  7:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 13:43 Waiting for deferred actions to finish alex0375
2017-01-09 19:43 ` Eric Wong
2017-01-09 19:45   ` [PATCH 1/2] tests: re-enable EventMachine tests, again Eric Wong
2017-01-09 19:45   ` [PATCH 2/2] eventmachine: wait for deferred actions to finish Eric Wong
2017-01-10  7:31   ` Waiting " alex0375

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

	../../../rainbows.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).