Rails, Textdrive, and Capistrano

The development box for chartpart was down for almost a day earlier in the week. Textdrive (aparently) had trouble with the shared host box on Sunday, and ended up having to take it down, reinstall the OS, etc. My rails app didn’t come back up after their reboot, and I couldn’t kick it back to life. Some of the hazards of shared hosting.

Since doing the original setup a few months ago using Geoff’s nice shovel cap script, a nice official guide to setting up Rails on Textdrive has been written, and things are in different locations, different mechanisms, etc. I ended up having to go through this process for chartpart, and it worked nicely.

I posted some earlier updates to shovel, but it looks like some more are needed if it’s going to reflect textdrive’s recommended config. Anyone done this work already?

This comes as our aplus.net value ($49/mo) dedicated server just came on-line. This is where chartpart will move for its “official” beta (can’t wait for Amazon’s hosting).

Selecting a Platform

I’m using Ruby on Rails for the charting service. How to make this kind of technology decision?

  • Maximize reuse — choose the technology that leaves you with the shortest distance to your solution
  • Consider the cutting edge — take the opportunity to gain the competitive advantage of a next-gen technology
  • Use what you know — temper the first two, knowing becoming a pro in a new technology is a huge investment

The last time I did any real web work was 1999 — building cosource.com on Linux, Apache, Mysql, and Perl (no PHP). Basically a big app running under mod_perl, which queries SQL and spits out HTML. So use what I know, or go cutting edge?

The decision was easy. The world has moved on in the last 7 years. Rails is an amazing platform — for getting something running quickly which minimizes batch size and encourages incremental development; for aligning with known design patterns so as not to reinvent the wheel; for integrated testing (TDD) and inline documentation which enables higher quality, lower-risk, pay-as-you-go development. Ruby is an amazing language — clean, dynamic. And the crowd creating and adopting these technologies are the best in the industry — from brilliant new stars to respected veterans. So these technologies continue to get better fast, to the benefit of anyone else adopting them.

So, over the last few months, I’ve bitten the bullet and tried to move through the knowledge curve from nuby towards ruby pro. And this charting web service is a good first project (in terms of size and technology risk) on which to learn.

Shoveling rails

I’m deploying a Rails application to textdrive using Geoffrey Grosenbach’s Shovel—Rails Deployment with Lighttpd. Thanks to Geoff for putting all his learnings into a script for the rest of us. Here’s some things I ran across on the way:

  • Textdrive has changed a few aspects of the server config. I updated Geoffrey’s script to cover one of the changes — users/home/[username]/sites is now users/home/[username]/domains. This is now one of the variables you should set for your case at the top of the script. I also added a variable for svn branch path, in case you use a trunk/branch/tag structure in svn as I do. This updated script is here.
  • Running the rake task, I was having this common problem with ruby require not finding the ‘openssl’ library. The solution on Ubuntu 5.10 (Breezy Badger) was to install libopenssl-ruby (sudo apt-get install libopenssl-ruby). Don’t be fooled, other packages like ‘openssl’, etc. are not what you’re looking for. A little commentary: I can’t recommend Ubuntu for Ruby/Rails developers — I’ve lost a lot of hours on various problems. The ubuntu/debian package maintainers are working at odds with Ruby’s distribution mechanisms (which works best when you can install ruby+rubygems and use gems to get everything else). Right now, Ruby on Ubuntu is broken in pieces and available in both places, without accurate dependency maps to help you get what you need. Until this is fixed, consider finding another alternative. If you have a Mac, I’ve had good experiences with DarwinPorts+gems.
  • Error messages in most of the tools here are not particularly helpful. Often it’s a Ruby exception where the real problem is only discernable way up the stack. Googling the error message (such as it is) is a good first step for debugging.
  • Textdrive has moved the ruby bin to /usr/local/bin/ruby. If a ruby script doesn’t work, check the top for this.
  • If you keep rails’ database.yml out of source control (e.g. if following subversion with rails), don’t forget to create it on the server now
  • After running the shovel script, /users/home/[username]/domains/[application]/current/config/lighttpd.conf wasn’t populated. Running script/server copied an example from the gems directory, but I needed to edit it to provide my textdrive-supplied port for lighttpd, and fix up the ruby location.

At this point, running ‘rake deploy’ and ‘rake rollback’ should work as intended if run from where I’ve checked out the production branch.
Some of the error messages that I hit before hitting on the solutions above:

  • (mod_fastcgi.c.1022) execve failed [turned out to be the /usr/local/bin/ruby problem]
  • no such file to load — openssl [sudo apt-get install libopenssl-ruby]

Any other updates or suggestions to do this better are welcome.

Azureus, Capistrano, and Vonage

A few things I learned from putting out RORVM last week:

  • When you publish a torrent, you can publish with a “torrent tracker” site, or do it “trackerless” (dht). I used Azureus to do it the trackerless way, and I think that was the wrong choice. Going trackerless reduces the ability for others to find the torrent, which then reduces the number of other seeders to help distribute it. So I’ll try a tracker for the next one, but I’m still not sure of the best tracker to use, though.
  • For a “Linux Appliance VM”, which mine is, you could imagine another means of distribution. Instead, download a standard VM image (say a straight Ubuntu Breezy 5.10 server install — or just the CD iso and install yourself) — and then re-configure the VM with a tool like Ruby’s Capistrano. So my instructions would change to 1. download ruby+capistrano to your PC. 2. download a straight Ubuntu VM. 3. download my capistrano script to re-configure the VM. Wouldn’t require a torrent on my part. But the cost of a few more steps to get it running.
  • If you do try to download my current VM image as it stands, you might find no seeds available. I was keeping Azureus running on my home box to make sure we had at least one seed, but I’ve had a problem — Vonage. I’ve been making full use of the Comcast cable connection, running a lot of stuff over it, including my home phone. Well, with the 40K of upload traffic that was consumed by seeding my torrent, we started having problems with “line is busy” or other errors in calling our Vonage number. Not 100% sure it’s cause-and-effect, and don’t know why Vonage isn’t falling over to the backup number, but I’m blaming it on the torrent for now, and may need to find another way.

Ruby on Rails Virtual Machine for VMware (RORVMv0.10)

[update: the .torrent is no longer up. I'd recommend using Ubuntu 6.06 or later, as the Ruby support is much cleaner]

I’ve been working on a project using the Ruby on Rails framework, which is ultimately deployed to a webhost running a Unix variant. At first, I was building this in an OS X environment, but then I had to switch over to a Windows laptop.

So in order to have a (at least somewhat) common development environment, I wanted to make use of some of the amazing progress that’s being made in virtualization software to do my development in a Unix VM on Windows.
So here is a very early, rough release of a VM intended to meet my needs (and perhaps yours). The basis of the VM is Ubuntu 5.10 (Breezy) Linux text-mode-only server. On top of that are Ruby and Rails packages, several fixes (for example, 5.10 comes with Ruby 1.8.3, which is incompatible with rails — so I upgraded the VM with Ruby 1.8.4 from Ubuntu 6.0), and some customization useful for running in a VM (e.g. prominantly displaying the DHCP-assigned IP address). All off-the-shelf open source pieces — thanks to the tons of people involved to make all that work, and to VMware for releasing a great, free VM “player”.
I’ll be tracking the rbuntu live CD work, as that comes out, possibly merging this work with that. I’m just making this available via Azureus torrents for now — it’s intended to be a minimal VM, but it’s still 250MB. :)
Steps to install RORVMv0.10

  1. Install VMware Player
  2. Install Azureus bittorrent client (.torrent below may only be avilable via Azureus’ decentralized tracking)
  3. Click the RORVMv0.10 .torrent file to have Azureus download it, and unzip.
  4. Click on the .vmx file to have VMware player run the VM. Follow directions before login.

Let me know if something just doesn’t work here, or if you have feedback or ideas to make this more useful.