Using Passenger on OS X
December 5th, 2008
Despite having been reluctant to ditch my ‘tried and tested’ method of Rails deployment using nginx/mongrel/monit I decided that I couldn’t ignore Phusion Passenger anymore and gave it a spin on my local machine for development work.
The passenger pref pane for OS X made setting up Passenger super easy and I was even able to set it up to respond to some wildcard subdomain apps I work on. Best of all it works with the default OS X Apache install so it makes for very few moving parts in your local development setup.
Based on the super success of using Passenger for development I’ve deployed a production application server for Litmus using Apache2/Passenger/Ruby Enterprise.
There’s another post in the works which outlines how we’ve scaled Litmus recently to handle a 500% growth in subscribers, the outline will be on the Litmus blog going into more detail on this site.
0 comments »Learning erlang
September 3rd, 2008
I’ve recently been trying to learn erlang for some infrastructure projects that will benefit from being written in a language better suited to long running data processing and queueing than Ruby ever will be. Hopefully we’ll have these projects up and running behind the scenes for Litmus in the near future.
Invaluable resources to me so far have been
- Programming Erlang book by one of Erlang’s creators Joe Armstrong
- Erlang in Practice by Kevin Smith – Kevin works with me at Engine Yard and is a great teacher and all round nice guy. These screencasts really got me going on the road to understanding and learning erlang. I highly recommend the entire series.
Mark in the sand
August 6th, 2008
Today I found an application just ready to launch which is exactly the same as a project I’ve been planning and building recently.
I thought I’d leave a mark in the sand here so if I ever do get round to releasing it – open source or paid – then I’ll have something to point back to and say “look, look – I had already thought of it and started work on it!”.
I won’t go into any detail now, I’m not a fan of vapourware.
Update: Every sod in the entire world is now implementing the idea I had. Oh well, onto the next one now then :)
0 comments »Allow some paths when your app is in maintenance
August 5th, 2008
Those of you who already follow Ezra's great guidance on setting up nginx as a front end to a mongrel cluster will know that it already includes a nice block to enable maintenance mode when you trigger it in capistrano (creates a /shared/system/maintenance.html page and rewrites all requests to it).
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
However, we had a customer the other day who wanted to put his application into maintenance mode but still get to the admin area. After much tinkering with nginx rewrite rules we came up with a solution that worked and also let you host your images and css from the same application without having those calls rewritten as well. Basically it just required a reordering of the rewrite rules within the location block to a more sane order.
See an example nginx config which implements this - based on Ezra's original to give the customer complete anonymity.
One important thing to note about this config is that if you serve images or css via processing in your mongrels this will skip processing them - indeed, anything that ends css, jpg, png or gif will never make it to mongrels and be served by nginx instead. Consider this and remove the relevant if statement if this applies to you. In particular this will apply to Mephisto which serves css via controller processing in order to then cache it out statically to disk.
0 comments »Shafted by FastHosts
August 4th, 2008
As most people will know, as well as my full time job at Engine Yard I am a co-founder of Litmus along with Paul and Matt.
We re-launched our previous product SiteVista as Litmus pretty much a year ago in August 2007, anniversaries are normally such a happy affair but in our case it has become anything but. As a small self-funded start up company running a service that is very hardware intensive we had to make some careful decisions – sure we’d love to have kicked off hosting with our own custom built cluster with the best hosting company in the business but it just wasn’t possible if we wanted to retain total ownership of the company.
Paul and Matt had both hosted applications with Fasthosts before, they had some of the best value servers at the time and meant we were able to get the servers we needed with the budget that we had. Just to be sure here, at no point have we scrimped on budget with Litmus or tried to just get the cheapest servers we can find. The service requires nearly 10 physical servers to run, all need to be a reasonable spec as nearly all of them have to run Windows operating systems and keep the UI very responsive. As you can imagine this is a fairly big financial burden for a start-up to bare, I’m very proud that we’ve managed this so well and coped with the massive increase in capacity as we’ve grown – this is a testament to Matt and his ace .net coding.
Read the rest of this entryMetaWebLog API returns to Mephisto
July 22nd, 2008
At long last it looks like the MetaWebLog API has made it back into Mephisto as a plugin. I had started working on this myself but it was just too low priority for me with all the various things I have going on at the moment.
I know it was the intention of the Mephisto core team to stop this API from depending on the now deprecated ActionWebService framework and have someone else move it onto its own independent xmlrpc code. But to be honest this has been too long coming to turn down the plugin, even if it is still relying on ActionWebService (there seems to be a newish port of it on GitHub that might keep up with the rest of Rails with a new committing team).
And so onto the plugin itself, just drop by the RailsHacks blog to pickup the code and instructions for use. If you can see this post then it definitely works as I’ve just written it in the awesome MarsEdit and posted directly to this blog using it.
1 comments »Me in Denmark
June 23rd, 2008
On Wednesday I will be flying out to Copenhagen to attend the Reboot conference on Thursday the 26th and Friday the 27th of June.
If you’re there – or nearby – and want to meet up with me or Paul (CEO of Litmus ) then just drop me an email from my contact form – we’d love to speak to you!
You’ll spot me possibly in my black Engine Yard t-shirt or you can recognise me from my picture otherwise.
Setting up Background Job (BJ) Properly
June 23rd, 2008
I dealt with a customer today who was a bit miffed that his Background Jobtasks were taking a while to kick off after the Rails app submitted them to the queue.
I dug a little deeper into the problem - he was using our standard configuration, moving control of the runner out to cron instead of being controlled from within the app itself.
1 |
Bj.config["production.no_tickle"] = true |
and then a cronjob such as
*/2 * * * * bj run --forever --rails_env=production --rails_root=/data/user/current
FireFox 3 triggers an OpenSSL bug
June 22nd, 2008
Secure Connection Failed
An error occurred during a connection to xyz-abe.com
SSL received an unexpected Change Cipher Spec record.
(Error code: ssl_error_rx_unexpected_change_cipher)
I’ve been seeing more and more customers report this in the lead up to FireFox 3 going live…now the release has come I think the only thing you can do is try and get your production servers upgraded to the latest OpenSSL (0.9.8h) as soon as possible. Unfortunately the only other work around involve users disabling something in about:config or disabling SSLv3 on your server.
Some background reading on the bug:
Additionally I’ve seen FireFox 3 introduce another bug related to incorrectly signed HMAC codes in SSL transactions. After some digging around I noticed that FireFox 3 supports the Camellia cipher which AFAIK isn’t widely supported amongst other browers yet. During SSL negotiation the browser seems to end up using Camellia even though it could have negotiated the more familiar AES cipher. I hacked around this in one clients nginx configuration by adding the following to their http block:
ssl_ciphers ALL:!CAMELLIA;
Hpricot Case Sensitivity
April 24th, 2008
Recently we were trying to use the awesome Hpricot to do some HTML parsing. Problem is that Hpricot doesn't easily allow you to do case insensitive searches for elements.
This means that we're missing any element where someone has placed an uppercase character in the tag we're explcitly looking for.
1 2 3 4 |
>> h.at("meta[@name=description]") => {emptyelem meta name"description" content"David Smalley, Ruby hacker based in Leeds, UK"} >> h.at("meta[@name=Description]") => nil |
This problem has been talked about on the Mofo Mailing List and even on the Hpricot challenge page - but I didn't really like the look of those solutions as downcase-ing everything would distort the original HTML.
So I devised this (horrible and hacky) bit of code that loops through all element names and attributes, downcase-ing them all without touching any innerHTML.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
def normalize(element) element.children.each do |child| if child.respond_to?(:name=) child.name = child.name.downcase if child.name end if child.respond_to?(:raw_attributes=) attribs = {} child.raw_attributes.each_pair do |key,value| attribs[key.downcase] = value.downcase if value end child.raw_attributes = attribs end normalize(child) if child.respond_to?(:children) end return element end >> h = Hpricot(open("http://davidsmalley.com")) => Hpricot.....<snip> >> normalize(h) |
Now all your element names and tags will be downcase-ed and all innerHTML will be left alone. Comments, feedback and suggestions very much welcome!
Shout - at a glance status
April 21st, 2008
Inspired by a recent 37 Signals blog post A peek at In/Out, an internal app at 37signals, we decided this would be great for the Litmus team as well. A quick glance overview of what everyone is working on at this moment in time.
Not wanting to go too overboard and create something we never went and updated, we decided to tie it into Twitter which we all use anyway. Direct Messages fit the bill perfectly as we weren’t too keen on broadcasting the inner workings of Litmus across the internet.
Merb was the framework of choice for this little web app. Using the Twitter Gem to check the direct mail of an account we set up, it then republishes the messages to a page we can all view inside our management app. Merb worked a treat, and we got the app up and running in a couple of hours, a quick style overhaul from Paul and we had the app live and in use from today.
We hooked the app into a Fluid browser and Paul knocked up a little applescript app that posts a direct message to the correct Twitter account.
We’re all really impressed with the result…

The plan is to release this app via Github once it has been cleaned up a bit and properly tested, check back here for details of its release.
I should point out that while we were playing around with this we called it “in/out” (that’s what appears in the screen shot) but obviously the fine people at 37 Signals have already used this name. Therefore our app is known as “Shout”.
Vendor everything in Merb
April 21st, 2008
I spent an evening trying to suss out how to use merb with all the gems unpacked into the local gem folder, turns out my problem was using
gem unpack <gemname>
in a local /your/app/gems folder does not work.
Instead you need to setup an entire new gem home within your merb app, complete with /bin, /doc etc. directories that gem is expecting. To set this up you just need to do the following inside your merb app.
mkdir gems
gem install <gemname> --no-rdoc --no-ri -i /your/app/gems
Note that if you install a gem with a dependency it will by default install all the dependencies as well. This means that installing merbful_authentication for example will also likely install the merb, merb-core and merb-more gems into your app local gems directory. I am not sure how you would proceed using gems that compile for local architectures (mongrel, hpricot, eventmachine etc.) which might get dragged in as dependencies but then end up being bundled with your project. The obvious problem there is your development and production environments (and possibly different developers environments) are likely to differ so checking a platform specific binary into source control isn’t the best idea.
It is important to note the --no-rdoc and --no-ri flags as these will stop you having a doc directory of documentation generated from every gem that you install to your app. You can alternatively set up your .gitignore or svn:ignore to not check these in to source control, but I prefer to just never generate them in the first place.
Hook up to IRC when your network blocks it
April 18th, 2008
Just a quick write up for my own reference really, but hopefully some other people will find it useful.
My office is hooked up to the academic JANET network in the UK and it turns out that IRC is completely blocked. This is less than ideal for my new job at Engine Yard which uses IRC extensively for customer support and communication between staff.
Rather than fight with IT department goons I managed to quickly setup irssi to proxy my IRC access via my dedicated server and avoid network port blocks. Here are the steps I followed:
- Download and install irssi (use the—with-proxy flag on configure) – see this doc for more info
- Set up irssi to access your chosen server and various options – see this doc
- Run irssi using screen so you can start and then detach it (this means you can log out and keep it running between sessions) – see this doc
- Connect your local IRC client to the server running irssi on the port you specified
- Use IRC!
Thanks to people on the Geekup mailing list for their help and advice
Exciting times
April 9th, 2008
This last weekend I was up at Scotland on Rails – met loads of great people and saw lots of interesting talks. Well done to the organisers for putting together a Ruby/Rails conference in the UK. It had been a long time coming since RailsConf Europe came (and went) to London a few years ago (as an aside, is this always going to happen in Berlin now? I had hoped it was going to do a grand tour of Europe).
At the conference I was offered a job with Engine Yard and I’m delighted to say that I accepted the offer and will be starting in May!
Big thanks to Jamie van Dyke for giving me the opportunity.
Extension-less Formats in ActiveResource
March 26th, 2008
When trying to integrate Litmus with Fetch recently we came across an API that whilst appearing RESTful, didn't quite map onto ActiveResource conventions because their URLs 404'd if we included .xml as the extension.
So I quickly whipped up a little plugin to let us specify new formats that don't include extensions.
1 2 3 4 5 6 7 |
class Something < ActiveResource::Base self.site = "http://someone:password@an-app.com" self.prefix = "/api/" self.format = :xml_no_extension end |
Now, calls to
Something.find(:all) |
Perfect!
You can grab the code from the ExtensionlessFormat GitHub repository

Feed me

