When Upgrades Go Bad January 27th, 2008
There have been a number of 500 errors on a freelance site I'm on. For the first round of troubleshooting, I'm updating the web server. My favorite web servers are nginx and lighttpd, but this dedicated server has two legacy apps, both built around Apache.
My favorite platform is Debian Linux because updates are fast and painless. This legacy server runs gentoo.
Unfamiliar Operating System + Unfamiliar Software == Disaster
At 11:00 pm I ran the upgrade. When it came back up, I found my Rails app working wonderfully. For safety, I checked the legacy PHP apps, and they were down. Hard.
It's midnight. I estimate I have until 8:00 a.m. before I'm in deep trouble.
After much research, I learned Gentoo decided to upgrade me from Apache 2.0 to 2.2, and 2.2 breaks a lot of things. One of which is fastcgi, now replaced with fcgid. I haven't used fastcgi in a year, since Mongrel makes it irrelevant for Rails. Fcgid will require much hacking.
It's 1:00 a.m. It's clear I'm better off installing mod_php. You'd think it's as simple as "sudo emerge mod_php". Well mod_php has merged with the base php package. you enable mod_php with a flag in some file. I enable the flag.
I start the compile at 2:00 a.m. And wait. And wait.
You see, Gentoo's philosophy that everything should be compiled from source. So for two hours, php compiled, just so I could get mod_php.
It's a little past 4:00, and things are back. What have I learned?
- PHP is harder to deploy than Rails
- Gentoo is for people with no sense of priorities
- Apache 2.0 to 2.2 is a nightmare. Changes that break things belong in a x.0 release.
Keeping up to Date January 25th, 2008
Many months ago, we changed from Prototype to jQuery, and couldn't be happier. Sadly, we had this recent commit.
$('.time').each(function(s) {s.innerHTML = date_string;})
This is some perverse hybrid of prototype and jquery. You see, jQuery selectors use the '#' and '.' to denote ID's and classes, respectively. Just like css. $('id_name') in prototype is the equivalent of $('#id_name') in jQuery.
Obviously, this javascript doesn't work. The submitter is not only out of the loop on our framework, but also so lazy as to not check their work. Yes, these people exist.
Formatting Dates January 17th, 2008
Wrong:
<% time = Time.now %>
<%= Date.today.to_s.gsub('-','/') %> <%= "#{time.hour > 12 ? time.hour - 12 : time.hour}:#{time.min}" %>
Right:
<%= Time.now.strftime('%m/%d/%Y %I:%M') %>
Please learn and love Time#strftime
Version Control Repository Structure January 15th, 2008
We noticed a project in our repository by a former developer. Its trunk was empty, but it had six branches. Yes, six. Six, six, six, six. Time for an introduction to repositories!
The Folders
A subversion repository, by convention, has the following folders.
Trunk
You put your app's code in trunk. You do development in trunk.
Branches
When you're making a significant change:
- Duplicate trunk and put it in the branches folder.
- Do development on the new branch.
- Merge the branch back to trunk.
- Delete the branch.
Tags
If you need an unchanging snapshot of code for when, say, you release 1.0, you put it in your /tags folder.
This isn't brain surgery
These are universal concepts. Different version control systems, like Git, represent branches differently (read: better), but it's the same idea. Maybe he was confused since subversion treats branches as just another folder. Maybe nobody taught him the finer points of version control.
Then I see-- in spite of our repeated lessons on test-driven-development-- this project has zero test coverage.
Never have I been happier with the word "former".