Sword 1.0b5 · A simple and friendly weblogging tool for academic environments created by Fingertips design & development.

 
 
 
 
 

Hanging FCGI-processes with Edge Rails and lighttp

TrackBack link: http://blog.markjuh.net/markjuh/trackback/2005/9/26/hanging_fcgi_processes_with_edge_rails_a

Published on 26 September 2005 at 14:51, updated at 14:51.

In category Rails.

For quite some time now, if you use lighttpd combined with Edge Rails, the Rails FCGI-processes don’t terminate when lighttpd terminates. This is strange, since lighttpd sends the TERM signal to the FCGI-processes. I had to use a kill -9 to actually end the FCGI-processes.

Rick Olson confirmed this behaviour and we tried to track it down. We couldn’t find it back then, but since then I got SO annoyed that I looked into it a bit more.

It seems that the problem is in vendor/rails/railties/lib/fcgi_handler.rb. It shows that the TERM signal is handled by the graceful_exit_handler. This handler sets whenready to :exit, which should make sure that the FCGI-process ends after processing the current or next FCGI-request.

And now this last part exactly forms the problem. When lighttpd terminates, the FCGI-process is waiting for the next request to come so it can finish gracefully. But the next request never comes, since lighttpd is already down, so there is no process to send requests to the FCGI-process.

So, I’ve written a dirty hack to fix this problem. David Heinemeier Hansson already promised to fix it the right way, but I just couldn’t wait for that to happen. (Using kill -9 every time you restart the webserver is just too annoying.)

Unexpected characters when using Prototype (AJAX)

TrackBack link: http://blog.markjuh.net/markjuh/trackback/2005/9/26/unexpected_characters_when_using_prototy

Published on 26 September 2005 at 13:27, updated on 2 October 2005 at 03:41.

In category Rails.

A little while back someone pointed me at the weird behaviour of my preview box when adding a comment. Somehow &_= was added to the end of the preview content.

It took me quite some time to figure out where it was coming from. I searched and searched, but couldn’t find the problem. I thought it wouldn’t be a Prototype bug, since Rails had been updated, but Prototype hadn’t changed.

So I asked around in #rubyonrails and Thomas Fuchs pointed me in the right direction.

It seemed changeset 2106 in Rails changed the way a Safari bug was tackled. It had been the case that Prototype added the &_= to the end of the POST data and ActionPack would strip this away again. But since another fix was found for this problem, there was no need for the &_= anymore.

So the following (line 213, or in the latest Edge Rails version line 476) should be removed from prototype.js:

if (parameters.length > 0) parameters += '&_=';

I had already discovered that removing the line fixed the problem, but it was good to find the reason why. And I’ve filed it as ticket 2258.