The problem
My existing script for publishing my blog has Pelican run on the web server and generate the static site directly into the directory served by nginx. This has the effect that while the blog is being published, it is inaccessible or some of the pages or styles are missing. The publish takes well under a minute, so this isn't a big issue, but there's no reason for any downtime at all.
The solution
Instead of serving the output/
directory, instead generate it
and then copy it over by changing the make publish
line in
schedule_publish.sh
to the following:
make publish || exit 1
if [ -L output_dir ]
then
cp -r output output_dir/
rm -rf output_dir/html.old
mv output_dir/html output_dir/html.old
mv output_dir/output output_dir/html
fi
where output_dir/
is a symbolic link to the parent of the
directory actually being served and html/
is the directory actually
being served (which output/
previously was a symbolic link to).