Archive for August, 2005

Grace and Dignity

Posted on August 31, 2005, under apache, general.

It’s only taken me 4 weeks, but as of last week httpd-trunk now supports a graceful stop, in both the worker and prefork MPM’s (for now, anyway). Depending on the status of the 2.1.7 release as a beta, graceful-stop may even make it into Apache httpd 2.2.0. All depending on how soon that happens.

So, now it’s possible to do “apachectl graceful-stop” and httpd will stop listening on any ports (they will be available immediately for any other process) but continue serving any requests which were active at the time of shutdown.

The default behaviour is to wait indefinitely until all of the active requests have been served, but a new directive “GracefulShutdownTimeout” also allows the administrator to specify how many seconds httpd should wait for exiting even if all requests have not yet finished. This directive, and a small bit of other code actually came from years-old work of Ken Coar and Bill Stoddard.

All of which means when we next upgrade httpd on ftp.heanet.ie, we won’t have to kill hundreds of active downloads, some of which can take hours to serve (think ISO downloads from dial-up). And as you can imagine, that really annoys some of our users. Instead, it’ll just be a matter of;

make install
apachectl graceful-stop
apachectl start

Thanks to some of the same code, if an administrator wants to be really fancy, they can actually rewrite httpd.conf to listen on different port, say 81, and issue an “apachectl graceful” (restart) and httpd will immediately unlisten on whatever port it was originally listening on. Which means the admin can still monitor what is being downloaded via mod_status.

Update: The event MPM is also supported.

The War on Error

Posted on August 25, 2005, under apache, general.

By commiting a stupid function prototype, which a compiler warning even showed up, I was reminded that I should be using a more efficient way to actually see errors in the middle of several hundred lines of regular output.

Last year, when we faced a similar problem, Brian Boyle and I wrote sexec, which is a tiny little wrapper program which colours stdout green and stderr red. Which means, I can do this;

cd httpd-trunk/
./config.nice
sexec make

and see this:

sexec in action

Through the magic of sexec, errors stick out a mile and are highlighted in red. Yes, on some platforms, gcc can provide colourised output, but this works with everything. See compiler errors, linker warning, make warnings, everything.

And where it comes in really useful is for automated builds or other automated tasks, because sexec can output XML. Here for example is what the error I missed, looks like when using:

1
-Wall -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wno-multichar -Wnested-externs -Wno-long-long -Wunused-variable -Wunused-value

For another example of sexec in use, take a look at the ftp.heanet.ie status page, if you click on a project name you’ll get the rsync output from the last run, green output good, red bad.

It doesn’t do proper HTML/XML encoding just yet, eg “&”‘s are output as literal ampersands, not “&”, but it’s good enough as-is for most purposes, especially interactive use. I can leave a compile in the background and spot a warning a mile away.

APR Hello World

Posted on August 17, 2005, under apache, general.

I went googling for a “Hello World” for the Apache Portable Runtime library, trying to track down a presentation Paul Querna gave at ApacheConEU and was surprised to find that I not only didn’t find his presentation, but couldn’t find any obvious “Hello World” example on-line.

Tracking down Paul’s presentation wasn’t hard, but to try and help anyone else who Google’s for it, here’s the code, taken directly from Paul’s presentation:

#include "apr.h"
#include "apr_file_io.h"
#include <stdlib.h>  /* For atexit() */

int main(int argc, char *argv[])
{
   apr_pool_t *p;
   apr_file_t *fp;
   apr_initialize();
   atexit(apr_terminate);
   apr_pool_create(&p, NULL);
   apr_file_open_stdout(&fp, p);
   apr_file_printf(fp, "Hello World" APR_EOL_STR);
   return 0;
}

While I’m posting it, I might aswell fill in the only blank for total newcomers to APR. Once configured, built and installed, APR will install the apr-1-config utility into $prefix/bin/. This utility tells you the exact arguments you need to use for compiling, linking and so on. For example, to compile helloworld.c;

gcc `apr-1-config --includes  \
    --cflags --cppflags --link-ld --libs`        \
    -o helloworld helloworld.c

Once compiled, you’ll have to make sure that libapr-1.so is in your LD_LIBRARY_PATH or in one of the directories ld.so has been configured to automatically search for libraries. That’s it.

colmmacc@lasaire:~$ ./helloworld
Hello World

If you write C, and you have portability requirements, it might be worth taking a good look at APR. It provides a lot of reliable abstractions for aiding portability, from simple things like a portable getopt to unified file-system and networking layer API’s. It saves me a lot of effort.

Dirvish, mod_ftp, mod_cache

Posted on August 17, 2005, under apache, general.

After an accident with mutt yesterday, I finally got around to setting up proper backups for loughan, the server this blog (amongst other things) is hosted on. With some help (or rather config stealing) from Brian Scanlan, we now have snapshot-like backups using dirvish, which means we can recover from stupid user mistakes aswell as cope with disk failures.

Its configuration format is truly bizarre, but once you get over it it’s a powerful backup tool which will maintain snapshots efficiently (using hard-links). Highly recommended, especially when you don’t have the budget for a real backup/restore system.

In other news, mod_ftp is progressing and incubation should start soon. Although mod_ftpd is out there, mod_ftp is coming from Covalent and has a lot of real-world deployment and features. It will probably be running on ftp.heanet.ie within a few days of incubation.

My own little plan is to make caching and proxying working, which will mean that we can cache often requested files as we do for HTTP, but also that in the future we can build a front-end load-balanced cluster serving HTTP and FTP but retrieve content via HTTP, acting as reverse proxies. Probably not all that useful to the general world, but I’ll be making it work.

To that end, I’ve been looking through

1
modules/cache/

in httpd’s trunk and cleaning it up. It’s surprising just how many boundary cases you can find when you start testing things thouroughly.

All of this means that the graceful stop work has been put on the backburner a little. I have the worker MPM in a state where it will stop gracefully, but it keeps a hold on the Listening TCP port, which won’t do. I’d like the port to be immediately free, just like sshd does with its graceful stop. I have a tingling suspicion that win32 is going to be an awkward case.

Pioneer DV565-A

Posted on August 1, 2005, under general.

While in Cork, we popped into Munster Sounds, which is exactly where Richer Sounds used to be and is in fact the same place, except that they replaced every instance of “Richer” with “Munster”. They had a few interesting things there, but the most to me anyway was the Pioneer DV565. It’s a DVD player, with component out, does progressive scan, will play SACD’s has component out for video, digital out for DTS/DDS aswell as analogue 6-channel out for SACD playing. All for €199, which sure isn’t bad. Oh, and it came in silver and multi-region pre-modded.

In the past I’ve mocked John Lyons for his intolerance of interlaced signals, but now with this thing hooked up to my projector I can definitely see the astonishing difference progressive scan makes. The images are much better, something I didn’t think possible considering how good it looked already.

The player is also much better at other things, it’s a programmable CD player for one thing, with some pretty complex programming options, and the UI is extremely well designed, making it easy-peasy to make come pretty complex configurations. The subtitles and menu options are anti-aliased, and very nicely too and it can all be tweaked in a lot of different ways.

It took a while to wire up to my amp and projector, but now that it is, I can definitely recommend it to anyone considering getting a good DVD player. Now, to buy some SACD’s and find a multi-channel HD PVR.

Weekend in Cork

Posted on August 1, 2005, under general, photography.

Noirin and I spent a pretty relaxing long weekend in Cork, the weather was o.k.-ish, but there was plenty to do anyway. We stayed at the Radisson SAS, Little Island, Cork. We’re slowly working our way through the Radisson hotels, since that’s where HEAnet conferences have been (and will be this year, in Athlone) and where I end up staying when on other company business, but since it only opened in June, this was our first time in the Cork hotel.

The room was very nice, and it’s also a spa-resort, which Noirin enjoyed, the pool was a good size and had lots of just for fun bubble-based features. It’s bar is pretty decent, better priced and better food than the Limerick Radission, but it has to be said the Restaurant is dire. Firstly, there rarely seemed to be more than about 10 people in it, when the room looked like it could serve at least 300 people. The vast cavernous emptiness and the retro 70′s decor on plush bench style seats arranged in a long row made it seem like probably the clostest thing to the Overlook hotel you can experience in Ireland.

Noirin got a great deal at short notice, which included 2 free treatments (she enjoyed both) and a free meal. We should have just skipped the meal. But otherwise, it’s an o.k. hotel, definitely good for business travel, but we’d probably not stay there again. Still well worth the weekend though.

Since it got mentioned in the Irish Times “What’s Hot” column that morning, we tried out the new Captain America’s in Cork City on the Saturday. One sentence review; it’s exactly the same menu and prices as in Dublin, only not as well prepared or tasty, try the accompanying Wagamamas instead.

Eighteen Turns

On the Sunday, we got a train out to Fota Island and saw Daniel Libeskind‘s Eighteen Turns, a really weird but interesting mesh of architectural steel.

I’ve put a Picasa photo-gallery for it and two other things I forgot to upload online.