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 »

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.