indexpost archiveatom feed syndication feed icon

Simple Automatic Site Generation

2024-02-25

How complicated could it really be to deploy this site? Some brief documentation and a test to ensure I have things working with a new "deployment" strategy to replace my old rsync workflow.

History

I used to do this:

rsync -Pavz posts/* nprescott.com:/var/www/html/idle.nprescott.com

The problem comes in when you factor in the full-text search database which needs a second call to rsync the sqlite database to the remote server. Two calls to rsync? Too many!

Just Use VCS Hooks!

Rather than do something very smart I figure I can lean on the DVCS I'm already using to sync and initiate rebuilds. In my case that is mercurial but the idea is reasonably transferable between other systems. Basically I set up a clone on this server to receive commits and hooks any changes into a call to rebuild. It ends up looking like this:

$ pwd
/home/nolan/idle-cycles-remote
$ cat .hg/hgrc 
[hooks]
changegroup = .hg/build.sh
$ cat .hg/build.sh
#!/bin/sh

cd /home/nolan/idle-cycles-remote/
hg update
/home/nolan/site-generator/generator.tcl /home/nolan/idle-cycles-remote/ /var/www/data/posts.db
cp -r /home/nolan/idle-cycles-remote/posts/* /var/www/html/idle.nprescott.com/

It isn't exactly elegant but it also seems reasonably foolproof. The site-generator directory is another remote of a Mercurial repository, albeit one that doesn't see many changes. So long as I remember to hg push nprescott.com when I am done writing I think it should basically just work without further maintenance. Possibly there are footguns if I get into history rewriting or doing silly things with the cache database but the resolution is to just delete it and rerun everything.