# Thin 0.5.3 Purple Yogurt release

**URL:** <https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492>\
**Category:** Ruby\
**Created:** [January 18, 2008, 6:23pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492 "2008-01-18T18:23:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 18, 2008, 6:23pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/1 "2008-01-18T18:23:31Z")

</div>

Hey all,

Version 0.5.3 (codename Purple Yogurt) of the fastest Ruby server is  
out!

Thin is a Ruby web server that glues together 3 of the best Ruby  
libraries in web history:

- the Mongrel parser: the root of Mongrel speed and security
- Event Machine: a network I/O library with extremely high  
scalability, performance and stability
- Rack: a minimal interface between webservers and Ruby frameworks  
Which makes it, with all humility, the most secure, stable, fast and  
extensible Ruby web server  
bundled in an easy to use gem for your own pleasure.

== What’s new?

Welcome 2 new members to the Thin team (previously composed of me and  
me):

- Kevin W. [http://www.almostserio.us/](http://www.almostserio.us/)
- James Golick [http://jamesgolick.com/](http://jamesgolick.com/)

Small release for \*nix users, but big one of windows users!

- win32 pre-compiled gem now available (send all your love to Kevin  
for this one)
- Add prefix option to thin script to mount app under a given path.

If you’re still not sure about trying Thin, here are a couple of  
articles:

- [http://glauche.de/2008/01/14/how-many-thin-server-instances-are-best/](http://glauche.de/2008/01/14/how-many-thin-server-instances-are-best/)
- 

[http://www.deze9.com/jp/blog/post?p=current-uptime-of-the-thin-server-process-behind](http://www.deze9.com/jp/blog/post?p=current-uptime-of-the-thin-server-process-behind)  
\*  
[http://blog.rayngwf.com/2008/01/thin-ruby-web-server-that-is-really.html](http://blog.rayngwf.com/2008/01/thin-ruby-web-server-that-is-really.html)

- [http://glauche.de/2008/01/12/thin-nginx-with-rails/](http://glauche.de/2008/01/12/thin-nginx-with-rails/)

== Get it!

sudo gem install thin

Might take some time for the gem mirrors to be updated, try adding  
–source [http://code.macournoyer.com](http://code.macournoyer.com) to the command if it doesn’t work

If you installed a previous alpha version (if you have 0.5.3 already  
installed)  
uninstall it before: sudo gem uninstall thin

WARNING:  
Thin is still alpha software, if you use it on your server you  
understand the  
risks that are involved.

== Contribute

If you’re using Thin, let me know and I’ll put your site on  
[http://code.macournoyer.com/thin/users/](http://code.macournoyer.com/thin/users/)

Thin is driven by an active community of passionate coders and  
benchmarkers. Please join us, contribute  
or share some ideas in Thin Google Group:  
[http://groups.google.com/group/thin-ruby/topics](http://groups.google.com/group/thin-ruby/topics)

Also on IRC: #thin on freenode

Thanks to all the people who contributed to Thin, EventMachine, Rack  
and Mongrel.

Marc-Andre Cournoyer  
[http://code.macournoyer.com/thin/](http://code.macournoyer.com/thin/)

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 4:16am UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/2 "2008-01-19T04:16:37Z")

</div>

This has been working so well on my Mac dev machine, I built it out on  
my RHEL server and started it with:

thin start -e production -p -d

This is dropping it in where a mongrel was. Listening on a high number  
port.

I can go to [http://rootdomain](http://rootdomain): and there’s my site.  
However, I can’t get to it using Apache’s mod\_proxy.

Killing the thin process and restarting the mongrel verifies that the  
proxy is set up right.

Any thoughts?

Thx

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 4:57am UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/3 "2008-01-19T04:57:36Z")

</div>

someone reported that the --user and --group options are not working :  
[http://groups.google.com/group/thin-ruby/browse\_thread/thread/a2483855a3d3380e/d796bf39b2b32d17](http://groups.google.com/group/thin-ruby/browse_thread/thread/a2483855a3d3380e/d796bf39b2b32d17)

maybe you’re experiencing the same issue. Can you check on w/ user is  
the thin process running?

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 5:44am UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/4 "2008-01-19T05:44:22Z")

</div>

On 18-Jan-08, at 10:15 PM, s.ross wrote:

> I can go to [http://rootdomain](http://rootdomain): and there’s my site.  
> However, I can’t get to it using Apache’s mod\_proxy.

Any luck with restarting or stop/start of apache?

With OS X 10.5 I’m doing that a lot now, never in 10.4 – if anyone  
knows what that’s all about, do tell.

Cheers,  
Bob

* * *

Bob H. – tumblelog at  
[http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
Recursive Design Inc. – weblog at  
[http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
[http://www.recursive.ca/](http://www.recursive.ca/) – works on  
[http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 3:49pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/5 "2008-01-19T15:49:05Z")

</div>

Thin runs in a single thread, no need for a mutex there.

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 7:43am UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/6 "2008-01-19T07:43:33Z")

</div>

Got it up and running … for a while. It’s running as root/root and  
I’m not certain why it was not responding to proxied requests, but  
I’ll have to track that down later. Here’s the puzzler for right now.

I decided to use the sitealizer Rails plugin for this site and it  
contains code such as:

```
 def store_visits
   begin
     mutex = Mutex.new
     mutex.lock
     $visits.each do |env|
       SiteTracker.create(
         :user_agent => env['HTTP_USER_AGENT'],
         :language => env['HTTP_ACCEPT_LANGUAGE'],
         :path => env['PATH_INFO'],
         :ip => env['REMOTE_ADDR'],
         :referer => env['HTTP_REFERER']
       )
     end
     open(File.dirname( __FILE__ )+'/last_update','w'){|f| f.puts

```

Time.now.to\_s}  
mutex.unlock  
rescue =\> e  
RAILS\_ENV == ‘production’ ? logger.info(e) : logger.debug(e)  
ensure  
mutex.unlock  
end  
end

This causes thin to crash as follows:

ThreadError (not owner):  
/vendor/plugins/sitealizer/lib/sitealizer.rb:80:in `unlock' /vendor/plugins/sitealizer/lib/sitealizer.rb:51:in`join’  
/vendor/plugins/sitealizer/lib/sitealizer.rb:51:in `use_sitealizer' /vendor/rails/actionpack/lib/action_controller/filters.rb:456:in`send’  
/vendor/rails/actionpack/lib/action\_controller/filters.rb:456:in  
`call' /vendor/rails/actionpack/lib/action_controller/filters.rb:435:in`call’  
/vendor/rails/actionpack/lib/action\_controller/filters.rb:637:in  
`call_filter' /vendor/rails/actionpack/lib/action_controller/filters.rb:619:in`perform\_action\_without\_benchmark’  
/vendor/rails/actionpack/lib/action\_controller/benchmarking.rb:  
66:in `perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/vendor/rails/actionpack/lib/action\_controller/benchmarking.rb:  
66:in `perform_action_without_rescue' /vendor/rails/actionpack/lib/action_controller/rescue.rb:125:in`perform\_action’  
/vendor/rails/actionpack/lib/action\_controller/base.rb:473:in  
`send' /vendor/rails/actionpack/lib/action_controller/base.rb:473:in`process\_without\_filters’  
/vendor/rails/actionpack/lib/action\_controller/filters.rb:624:in  
`process_without_session_management_support' /vendor/rails/actionpack/lib/action_controller/ session_management.rb:114:in`sass\_old\_process’  
/vendor/plugins/haml/lib/sass/plugin.rb:116:in `process' /vendor/rails/actionpack/lib/action_controller/base.rb:326:in`process’  
/vendor/rails/railties/lib/dispatcher.rb:39:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/lib/rack/adapter/ rails.rb:52:in`serve\_rails’  
/usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/lib/rack/adapter/  
rails.rb:67:in `call' /usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/lib/thin/ connection.rb:30:in`process’  
/usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/lib/thin/  
connection.rb:16:in `receive_data' /usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.10.0/lib/ eventmachine.rb:1056:in`event\_callback’  
/usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.10.0/lib/  
eventmachine.rb:224:in `run_machine' /usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.10.0/lib/ eventmachine.rb:224:in`run’  
/usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/lib/thin/server.rb:  
55:in `listen!' /usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/lib/thin/server.rb: 44:in`start!’  
/usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/bin/thin:85:in `start' /usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/bin/thin:116:in`send’  
/usr/local/lib/ruby/gems/1.8/gems/thin-0.5.3/bin/thin:116  
/usr/local/bin/thin:19:in `load’  
/usr/local/bin/thin:19

Any thoughts?

Thanks

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/7 "2008-01-19T16:51:30Z")

</div>

And even if it would be multi threaded it won’t work. Every time  
store\_visits methods is executed new mutex is created, so there won’t  
be synchronization.

> Thin runs in a single thread, no need for a mutex there.

> > ```
> > :referer => env['HTTP_REFERER']
> > 
> > ```
> > 
> > end

–  
Rados³aw Bu³at

[http://radarek.jogger.pl](http://radarek.jogger.pl) - mój blog

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/8 "2008-01-19T16:52:46Z")

</div>

> And even if it would be multi threaded it won’t work. Every time  
> store\_visits methods is executed new mutex is created, so there won’t  
> be synchronization.

The reason for error message "ThreadError (not owner):  
/vendor/plugins/sitealizer/lib/sitealizer.rb:80:in `unlock’  
(…)  
"  
is that you call ‘unlock’ method twice. ‘ensure’ block is ok, so  
remove previous calling (a the end of begin block).

–  
Rados³aw Bu³at

[http://radarek.jogger.pl](http://radarek.jogger.pl) - mój blog

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 6:55pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/9 "2008-01-19T18:55:00Z")

</div>

Oooooh, you’re right. Unlock is called twice. This is code in a Rails  
plugin, and I know that’s no disclaimer of responsibility for its  
working right. I still have to take responsibility for that. I’ll let  
the author know, but here’s a follow-on question.

Assuming bad behavior on the part of the client code (in this case,  
calling unlock twice), should this be rescued, the error logged, and  
an attempt made to keep the server alive or should the process  
terminate (as it currently does)?

I believe the intent was well-intentioned but that it doesn’t prevent  
concurrency issues cross-process and obviously provides no benefits in  
a Rails process because Rails puts a great big mutex around the whole  
request/response pipeline.

Thanks for looking into this.

–steve

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/10 "2008-01-19T19:47:23Z")

</div>

Of course it depends on specific situation but in about 99% situations  
you should log error and give message to user describing what was  
wrong (it could be even well known rails message “something went  
wrong” ;)). Of course there exceptions that you should explicitly  
rescue and exceptions that are very generic to catch every time.

For example, when I implement authentication I do:  
def signin  
user = User.authenticate(params[:login], params[:password])  
#(…)  
rescue User::AuthenticationException  
flash[:error] = “error message”  
end

But of course I can make mistake somewhere and for example I could get  
exception because I call method on nil object (NoMethodError  
exception). In this situation you can use rails handling exceptions  
mechanism (Ryan B. to the rescue -  
[#53 Handling Exceptions - RailsCasts](http://railscasts.com/episodes/53)).

So for global handling you can write:  
def rescue\_action(exception)  
case exception  
when NoMethodError  
render :text =\> “ups…”  
else  
super  
end  
end

–  
Rados³aw Bu³at

[http://radarek.jogger.pl](http://radarek.jogger.pl) - mój blog

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 8:33pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/11 "2008-01-19T20:33:49Z")

</div>

> I have a rescue\_exception function but this problem is happening in a  
> place where it kills off the server. It doesn’t do the same with  
> mongrel and I’m not sure why.

Which server do you use? Maybe it doesn’t handle all kind of  
exceptions (in this case ThreadError)?

–  
Rados³aw Bu³at

[http://radarek.jogger.pl](http://radarek.jogger.pl) - mój blog

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/12 "2008-01-19T19:57:56Z")

</div>

On Jan 19, 2008, at 10:46 AM, RadosÅ‚aw BuÅ‚at wrote:

> Of course it depends on specific situation but in about 99% situations  
> you should log error and give message to user describing what was  
> wrong (it could be even well known rails message “something went  
> wrong” ;)). Of course there exceptions that you should explicitly  
> rescue and exceptions that are very generic to catch every time.

I have a rescue\_exception function but this problem is happening in a  
place where it kills off the server. It doesn’t do the same with  
mongrel and I’m not sure why.

–steve

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 22, 2008, 5:16am UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/13 "2008-01-22T05:16:02Z")

</div>

On Jan 19, 2008, at 11:32 AM, RadosÅ‚aw BuÅ‚at wrote:

> > I have a rescue\_exception function but this problem is happening in a  
> > place where it kills off the server. It doesn’t do the same with  
> > mongrel and I’m not sure why.
> 
> Which server do you use? Maybe it doesn’t handle all kind of  
> exceptions (in this case ThreadError)?

You were exactly right about the problem being that the mutex was  
unlocked twice. I have the site running now (in production mode on my  
production server ) and it seems just fine.

The biggest difference between mongrel and thin in this instance was  
that the double unlock killed thin, while mongrel continued on through  
the error.

thanks

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 19, 2008, 8:53pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/14 "2008-01-19T20:53:49Z")

</div>

On Jan 19, 2008, at 11:32 AM, RadosÅ‚aw BuÅ‚at wrote:

> Which server do you use? Maybe it doesn’t handle all kind of  
> exceptions (in this case ThreadError)?

Typically, I use Apache proxied to mongrel. It, evidently, does gobble  
up ThreadError. This was a proof of concept for Apache proxied to  
Thin. It does not behave the same in identical circumstances on the  
same machine (same port, environment, etc.).

---

<div class="post-metadata">

**Author:** ![macournoyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e495f1/32.png) [@macournoyer](https://www.ruby-forum.com/u/macournoyer)\
**Post date:** [January 22, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/thin-0-5-3-purple-yogurt-release/126492/15 "2008-01-22T15:44:17Z")

</div>

hey steve,

I tried reproducing your error causing Thin to crash. I was able to  
reproduce the error, unlocking a mutex twice, but the ThreadError was  
properly caught by Thin rescue block.

If you can help me reproduce this please add any details to  
[http://thin.lighthouseapp.com/projects/7212/tickets/1-uncaught-threaderror](http://thin.lighthouseapp.com/projects/7212/tickets/1-uncaught-threaderror)

thx,  
Marc
