Running Ruby on Rails with Apache 2 and mod_fcgid

My hosted Linux server runs Debian Sarge 3.1 with Apache 2. As most Ruby users have heard Apache 2 is rumored to be problematic with FastCGI. This evening I’ve been working on putting up a new Ruby on Rails site and the deployment aspect had me a little worried. I already host a bunch of sites on the box (Java and PHP) and moving them all to Apache 1, Lighttpd, or Mongrel and then thoroughly testing them was a depressing prospect.
Continue reading

Posted in Ruby, Systems Administration | Leave a comment

Use env to ensure a script will work in cron

I’ve often written scripts only to discover once added to crontab that it relies on an environment setting such as having the java command in the PATH or having CVSROOT set. To avoid this I now run scripts I’m developing for cron with

env -i

to simulate the script running without an environment as follows:

env -i somescript.sh

This has greatly increased my success rate of adding a script to cron and having it work from the get go.

Posted in Systems Administration | 1 Comment

Avoid hard-coding the path to the interpreter in your scripts

In general when trying to write portable scripts don’t start them with

#!/bin/bash

, instead start them with

#!/usr/bin/env bash

. The only caveat is that you DO NOT want to do this for critical security scripts because it opens you up to path based exploits.
Continue reading

Posted in Ruby, Systems Administration | 4 Comments

Creating database test fixtures and the rails export fixtures plugin

Being able to quickly and easily create test fixtures for your database is important yet it’s not always easy. There are basically 3 approaches I’ve seen used:

1. Use a MySQL or PostgreSQL dump that gets imported before the tests are run. I’ve never seen this approach used with Oracle, most likely because it’s such a PITA to export to text (or at least it used to be)
2. Just create the schema before the tests and then populate the test data in code
3. Use a database test fixture tool such as the XML based DBUnit for Java or Ruby’s YAML based fixtures
Continue reading

Posted in Database, Java, MySQL, Ruby, Software Engineering | 3 Comments

Unix and Windows Sysadmin in downtown San Francisco

My buddy Mike at UrbanaSoft is looking for an experienced full-time Unix and Windows sysadmin in downtown San Francisco. Pay is between $80-$100k depending on experience plus benefits and all that good stuff. If you’re qualified and interested or know someone that is email your resume to mike at urbanasoft dot com and mention that you learned about the job from my blog.

Posted in Systems Administration | Leave a comment

Moving MySQL tables live with zero downtime

The biggest challege to moving large amounts of data into production with (almost) zero downtime with MySQL is that the old table will be dropped and the new table locked while you’re loading the data. If you try that while serving a lot of traffic you’ll get into trouble as the database connections start stacking up waiting for the lock to free on that table and then you’ll hit max connections giving most of your users a 500 error.

If you need to move big tables live you basically have 2 options: Continue reading

Posted in Database, MySQL, Systems Administration | 2 Comments

Using log4j to monitor web application errors

When monitoring a production website (especially with a dozen or so application servers) you don’t want to rely on combining the logs and reviewing them manually for exceptions, you want the servers to notify you when there’s a problem. There are really 3 pieces to doing this properly and they are:
Continue reading

Posted in Java, Software Engineering, Systems Administration | 3 Comments

Hibernate with the MacBook Pro

Thanks to Dion for pointing out how to get your MacBook to hibernate! When I wrote about switching to the MacBook Pro one of my complaints was that upon shutting the lid the laptop doesn’t hibernate, it sleeps, and they offer you no easy way to switch it via the GUI.
Continue reading

Posted in Desktop, OSX | 9 Comments

Orbitz struggling with basic math

Update 4/20/06: I received the initial message from Orbitz that they had found my target fare of $294 which according to them is less than my target price of $250. Then this morning I received a message that they are still searching and the best they could find is $263 which today they consider to be above my target price. Perplexing!

When I lived in Germany taxes and fees were always included in the quoted price and that’s the way it should be! As a consumer when I make a purchase I want to know how much I’ll be paying but in the US many companies try to play consumers with misleading advertising that doesn’t include fees and taxes which can add over 30% to the price. Airlines, rental car agencies, hotels, and EBay vendors are some of the worst offenders, advertising prices well below what you’ll actually pay.
Continue reading

Posted in Humor, Life, Travel | 5 Comments

Why nobody is web testing in Java

Go into any IDE and create a default Web project and you’ll often get JUnit, but I have yet to see one include some form of web testing support (e.g. Cactus, Cargo, and HttpUnit) and that’s just lame! Continue reading

Posted in Java, Ruby, Software Engineering, Web | 3 Comments