This Space for Rent

New Code!

When pell exploded for the second time this week, I up and moved TSFR over to a different machine so that the silly thing wouldn't be offline for the two and a half days it took me to go downtown, push the Big Red Switch, and turn off the rapidly decaying swap disk. But while I was reconfiguring after moving the webserver over (rsync is my friend; I do nightly backups from pell to downbelow (using rsync) so getting the weblog over to the new machine was simply a case of firing up rsync and waiting half a hour while 1.2gb was shoved across the wire (oh, and then tweaking Annotations so it would work on an Apache server)) I checked my referrer logs and noticed a distressingly large number of requests coming in for pell.portland.or.us, which was no longer the same machine as weblog.etc.

While Pell was dead, I could just change the DNS to point pell at gehenna, but after I rebooted it I had to change that DNS back, at which point the hits started rolling in against the older copy of the weblog.

Pell doesn't run Apache; it runs thttpd, which, even though it's a nice efficient webserver, doesn't appear to do domain redirects(?). There wasn't any way I was going to run apache just to do the few hundred redirects a day that I needed, and the only pre-written code I could find was written on one TDV-L or another, and, worse yet, written in versions of those languages that I don't have on pell.

So, if I wanted to redirect http request, I had to write a program to do it from scratch. So I did.

redirect.c is a tiny little non-threading webserver that returns 302s for every request that it receives. I run it from the command line with the command redirect -v http://weblog.pell.portland.or.us, and it cheerfully tells any caller that their request (whether or not it is valid) can be found at the proper website under the same name. The program daemonises itself automatically, and I've got a fairly elaborate message function that directs messages to stderr or to syslog, depending on whether the program is running in the foreground or background.