Rainbows! Rack HTTP server user/dev discussion
 help / Atom feed
From: alex0375@gmail.com
To: rainbows-public@bogomips.org
Subject: Waiting for deferred actions to finish
Date: Mon, 9 Jan 2017 16:43:48 +0300
Message-ID: <CAKwvcL-VH3we4qA1pkNAstTmWvqNA=Rir2N_YiWztV_qbaLQvA@mail.gmail.com> (raw)

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!

             reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 13:43 alex0375 [this message]
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

Reply instructions:

You may reply publically 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://bogomips.org/rainbows/

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

  git send-email \
    --in-reply-to='CAKwvcL-VH3we4qA1pkNAstTmWvqNA=Rir2N_YiWztV_qbaLQvA@mail.gmail.com' \
    --to=alex0375@gmail.com \
    --cc=rainbows-public@bogomips.org \
    /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

Rainbows! Rack HTTP server user/dev discussion

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

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/
       or Tor2web: https://www.tor2web.org/

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