Skip to content

Commit

Permalink
Atomically replace the output directory
Browse files Browse the repository at this point in the history
The old method of removing output/ completely before regenerating it leaves a
small window period of 404s. This eliminates this window period entirely.
  • Loading branch information
hyperair committed Nov 25, 2014
1 parent f7799e9 commit a8cabed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
output/
output*

node_modules/
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
all: clean
all:
npm install
node bin/newevents.js
punch g

# atomically replace output symlink
ln -fsT output-new output-lnk
mv -T output-lnk output

# update output-current
rsync --delete -a output-new/ output-current/

# atomically replace output symlink
ln -fsT output-current output-lnk
mv -T output-lnk output
rm -rf output-new

clean:
rm -rf output
rm -rf output*

deploy: all
# Publishing to http://hackerspace.sg.s3-website-ap-southeast-1.amazonaws.com/
Expand Down
2 changes: 1 addition & 1 deletion bin/htaccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {

// Empty path means it's the last thing it does
if (!path) {
fs.createReadStream('htaccess').pipe(fs.createWriteStream('output/.htaccess'));
fs.createReadStream('htaccess').pipe(fs.createWriteStream('output-new/.htaccess'));
}

return callback();
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template_dir": "templates",
"content_dir": "contents",
"output_dir": "output",
"output_dir": "output-new",

"server": {
"port": 9009
Expand Down

0 comments on commit a8cabed

Please sign in to comment.