Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: Rainbows! list <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Cc: Damian Janowski <jano-eWlILCNyKRBBDgjK7y7TUQ@public.gmane.org>
Subject: Re: Out of band stuff?
Date: Mon, 9 Apr 2012 03:05:52 +0000	[thread overview]
Message-ID: <20120409030552.GA24089@dcvr.yhbt.net> (raw)
In-Reply-To: <CABAijKERMfjWzz9d8RxneV9eRJYLY6uSfEb9DEbhJh3jKLJ__w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Damian Janowski <jano-eWlILCNyKRBBDgjK7y7TUQ@public.gmane.org> wrote:
> Hello everyone,
> 
> I'm needing to perform a couple of tasks outside of the request cycle.
> For instance, I want to ping a web service every X minutes so that I
> can maintain a persistent connection to it and have better response
> times for some requests that I have to do *inside* the request cycle.
> 
> What would be the reasonable way of doing this?

For Raindrops::Watcher, I start a background thread on the first request:

	git clone git://bogomips.org/raindrops.git
	$EDITOR lib/raindrops/watcher.rb

If you look at the `call' method in raindrops/watcher.rb, the important
line is this:

	# @start is a Mutex and @thr is nil in the initialize method.

	@start.synchronize { @thr ||= aggregator_thread(env["rack.logger"]) }

I avoid starting the background thread at initialization because it'll
die on fork (meaning I'd have to recheck it all the time, anyways).

The overhead of Mutex#synchronize and @thr||= assignment is negligible
in most apps.

> I'm thinking the OOB GC is just another example. But the current way
> the OOB GC is written makes one think it's a very specific case and
> not something one should use for other purposes.

Yes, Unicorn::OobGC is very specific to how Unicorn works and the way it
works wouldn't translate well to Rainbows! (as Rainbows! does persistent
connections and unicorn does not).
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


  parent reply	other threads:[~2012-04-09  3:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-06 21:49 Out of band stuff? Damian Janowski
     [not found] ` <CABAijKERMfjWzz9d8RxneV9eRJYLY6uSfEb9DEbhJh3jKLJ__w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-09  3:05   ` Eric Wong [this message]
     [not found]     ` <20120409030552.GA24089-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-04-09 13:04       ` Damian Janowski
     [not found]         ` <CABAijKEa3Z9ZBFS-jX8wcvqjZ14sxKsPMbuESRvZOeLhRNBiCQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-10 20:16           ` Eric Wong
2012-04-10 20:24       ` Damian Janowski
     [not found]         ` <CABAijKG0srUSc4VEk35yd9jj1NAz9VJMqLZ3Uh_xeiObgTmXvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-10 20:37           ` Eric Wong
     [not found]             ` <20120410203743.GF25426-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-04-11  1:20               ` Damian Janowski

Reply instructions:

You may reply publicly 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://yhbt.net/rainbows/

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

  git send-email \
    --in-reply-to=20120409030552.GA24089@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=jano-eWlILCNyKRBBDgjK7y7TUQ@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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