Between 9pm and 10pm PST last night, Dreamhost (and reportedly TextDrive) decided to upgrade to Rails 1.1, resulting in mass havoc, confusion, and probably a few tears. Typo isn’t compatible yet, so bloggers all across the Rails-o-sphere cried out in silence.
Personally, I was hoping for such a world-ending event so I could try my new server monitoring tool. It worked!
But first….
For Typo (or other Rails apps), you can fix it by copying Rails 1.0 into the “vendor” folder. Of course, if your app isn’t running, you can’t do this on your server. Here’s what I did:
1. Freeze Rails 1.0 on any Rails app on your computer:
rake freeze_edge REVISION=3303
2. Copy the newly frozen contents of “vendor/rails” to your remote app’s “vendor/rails” folder.
Or, some people are having both success and failure by doing this on the remote server:
svn export http://dev.rubyonrails.org/svn/rails/tags/rel_1-0-0/vendor/rails
Ryan Davis has repeatedly recommended dwatch, a simple app that you run with cron. It reads a config file and checks to see if sites are responding. You can also have it scan the list of currently running processes on a machine. In either case, it runs a command of your choosing if the service is down.
I dusted off my C reference and expanded it to run the curl command to see if a running site returns an error (an HTTP status code of 400 or greater). Here is the modified app:
Download dwatch Server Monitoring Tool
I run this with cron every hour. If there is an error, I have it echo an error message. My shared host (Dreamhost) automatically emails me the output of cron tasks, so I get an email when something goes wrong. If everything is fine, it is silent and no email is sent.
Here’s what I saw in my inbox after Dreamhost upgraded to Rails 1.1:

Installation is pretty simple, but requires the compilation of a C file. Unzip the app on your server and do:
make make install PREFIX=~
I use prefix-tilde so it installs in my home directory. All that matters is that you have a “bin” directory for the compiled app to be copied to.
It expects to find curl in ”/usr/bin/curl”, which seems to be the default for Linux and Mac OS X. You can also configure that with a flag to make (see the README).
Cron is a standard Unix tool to run tasks at regular intervals. I make a file with my cron tasks and load it into cron all at once.
# Local crontab config file # Save as my_cron_tasks.txt @hourly /home/topfunky/bin/hourly.sh @daily /home/topfunky/bin/daily.sh
Load that file into cron with this command:
topfunky$ crontab my_cron_tasks.txt
The hourly shell script looks like this
#!/bin/sh # Hourly shell script # (You might be able to do this with # paths relative to your home directory.) /home/topfunky/bin/dwatch -f /home/topfunky/conf/dwatch.conf
Finally, make your hourly shell script executable so it can be run:
topfunky$ chmod +x bin/hourly.sh topfunky$ chmod +x bin/daily.sh
In summary, that will run the hourly shell script once an hour (the exact minute varies). The hourly script runs dwatch with its config file. If dwatch produces any output, it will be sent to the administrator’s email (depending on your shared host).
You can also pipe the output of the hourly script to the “mail” command. See “man mail.”
Earlier I said that I have dwatch configured to check a few sites and echo a message if an error happened.
Dwatch can check any site and perform any command if the site is unreachable. Here’s a sample:
# Sample dwatch.conf H "nubyonrails.com/tools/pluralize" echo "The pluralizer returned an error!" H "nubyonrails.com" echo "nubyonrails returned an error!"
The H is my addition…it checks the HTTP status code of the site. The second part is the site (or page) to check. The last element is the command to run.
The built in options also include T (check for a TCP listener…you must specify a port) and P (checks the local process list for a running process that matches).
Enjoy!
Very nice monitoring tool.
Dreamhost’s Rails upgrade appears to be in a bad state however.
Nice one brotha! I need this…
Thanks for posting the freeze fix.
Thanks Geoffrey. That monitoring tool will come in very handy.
Hmmm.. I haven’t noticed any problems w/ any of my Typo blogs. I’m over at TextDrive. Has anyone confirmed that TextDrive upgraded?
Ack!! I’ve been freaking out all morning! Thanks for posting this – you helped me fix most of my sites. I still have one that’s not working – it’s a Typo install that I’ve heavily customized, so there’s something else going on. This monitoring tool looks great – I’m looking forward to checking it out.
A note to folks on TextDrive: dwatch is probably verboten, since it’s just like daedalus. And daedalus was for dinner this year.
But daedalus was bad because of how people used it (i.e. trying to restart lighty every 5 minutes, frying servers).
If you use dwatch to send yourself an email when the server dies, you’re being a polite server inhabitant. Also, daedalus ran constantly, where dwatch runs occasionally with cron.
Even if TextDrive does ban it from running on their servers, you could run it on your local machine and it would still notify you when things go to hell.
Check out Montastic: free website monitoring service based on Rails. Provides site status also via RSS and Yahoo widget.
dwatch is nice tool, but if You need to monitor many hosts with many services You may want to look to nagios. I’m using it to monitor our server farm (mail,db,www,rails servers)
Hi topfunky,
This has nothing to do with the upgrade – but my (poor) experience with Typo on Dreamhost.
Ive followed your instructions and have frozen my copy of typo on dreamhost – I also successfully installed DWatch on my server. Now I knew in the past that my Typo install wasnt running very reliably on Dreamhost – but now with an hourly DWatch cron – I can see that it falls over about 5-10 times a day !! I get the dreaded ….
Application error Typo failed to start properly”
It this generally accepted performance with Typo running in a shared hosting box like Dreamhost ?
Im running a vanilla Scribbish Theme on typo – in rails production mode. Also – occasionally I get huge Core.* files being generated in my typo/public directory – have you ever seen that ?
How do you have your own TopFunky Typo install setup on dreamhost ? Is there something i am missing here? – with performance this bad I may have to ditch Typo altogether – which is a shame.
Appreciate any help,
Thanks,
Matt
It is great these articles are written. This will increase the ever increasing popularity of ruby on rails.