Rainbows! Rack HTTP server user/dev discussion
 help / color / 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, back to index

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

Rainbows! Rack HTTP server user/dev discussion

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

Example config snippet for mirrors

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

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

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