Posted by Tom Copeland on 22 September 2009 00:00
Originally published on Tom's Blog at tomecopeland.blogs.com
Yesterday Ryan Davis and I released v2.0.0 of the "rubyforge" gem. The big change for this version is that it no longer interacts with RubyForge by scraping HTML; instead, it uses the new RubyForge REST API. So instead of POST'ing a form to login and fetch your project list, it uses HTTP Basic authentication and hits /users/zenspider/groups.js.
If you're using the new gem, you may see this when you run rubyforge config:
$ rubyforge config
/Library/Ruby/Gems/1.8/gems/json-1.1.7/lib/json/common.rb:122:in `parse':
618: unexpected token at '<?xml version="1.0" encoding="UTF-8"?> (JSON::ParserError)
<!DOCTYPE html
[ ... lots more ... ]
That's happening because your ~/.rubyforge/user-config.yml file is telling the rubyforge gem to hit https://rubyforge.org, and it needs to hit http://api.rubyforge.org instead. To fix that, either run rubyforge setup, or just edit your ~/.rubyforge/user-config.yml and change the uri setting.
I'm happy to have a REST API for RubyForge available; this has been in the works for a few months and I hope folks come up with some interesting ways to use it. It's certainly much easier (and much more efficient) than the old way of using Mechanize or whatever to parse the HTML. Not all the RubyForge resources are available yet, so if you want to access something and don't see it in the API please let me know and I'll add it. The code is here and feedback is of course welcome. Enjoy!
Posted by Tom Copeland on 05 June 2009 00:00
A few months back schmalowsky (not sure of real name) posted to the Passenger issue tracker about a patch to limit Passenger memory usage. It's kind of a brutal patch in that it uses setrlimit, so if the process tries to allocate too much memory it just dies. But hey, it keeps one Passenger process from gobbling up all the memory on the box, and you don't need Monit to watch it, so, good enough.
That said, the patch is a few months old and the Passenger source code has moved around, so the patch no longer applies cleanly. I've brought it up to date and you can get the diff here. It seems to work fine - when I set it low enough the process gets put down as soon as it exceeds the threshold.
To try this patch out, do something like this:
git clone git://github.com/FooBarWidget/passenger.git
cd passenger
wget http://infoether.com/~tom/passenger_memlimit.diff
git apply passenger_memlimit.diff
rake package:gem
sudo gem install pkg/passenger-2.2.2.gem --no-rdoc --no-ri
sudo /usr/local/bin/passenger-install-apache2-module --auto
# now edit your httpd.conf and add "PassengerMemLimit 192M"
/sbin/service httpd configtest
sudo /sbin/service httpd restart
I fiddled with this patch for quite a while on my Macbook - but setrlimit(RLIMIT_RSS, nnn) doesn't seem to be taking effect. The function call is returning 0, and a subsequent getrlimit returns the value that I just set, but the process size grows and grows regardless. Not sure what's up with that. This is on OS X 10.5.7, Darwin Kernel Version 9.7.0. If anyone has insights into that please send them my way, thanks! Update: Eric Hodel tweets "setrlimit wasn't fully implemented on OS X, RSS and others are missing." Thanks Eric!
Also, mad props to schmalowsky for writing the original code. All I did was juggle it around a bit; the real work was already done. And of course a huge thanks as always to the Phusion guys for Passenger!