normalperson at yhbt.net
Wed Jan 12 23:26:36 EST 2011
Jimmy Soho <jimmy.soho at gmail.com> wrote:
> Take for example activesupport's usage of Time.zone. Under water this
> is set in a thread local var. If you set Time.zone in one request, but
> not in the next request, using unicorn the next request will use the
> time zone of the previous request. Using rack or mongrel (in
> multithreaded mode) you don't have this issue perse (though they have
> other issues then).
> Same for the i18n gem and it's usage of the I18n.locale value, which
> is also set in a thread local var.
> So yeah, unfortunately I have to take into account this "crappy idiom"
> and need to know exactly which thread local vars are set by all the
> components we use, and determine which of those must be reset before
> each request.
You can probably just write a trivial middleware to clear all
keys in Thread.current before every request. Or play around with
Rainbows! with a single-threaded ThreadSpawn:
cat >> unicorn.conf.rb <<EOF
And then just run "rainbows" instead of "unicorn".
More information about the mongrel-unicorn