Skip to content

Commit

Permalink
Simpler Atomic update
Browse files Browse the repository at this point in the history
  • Loading branch information
kaihendry committed Nov 27, 2014
1 parent fcc959f commit 5252d3a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
22 changes: 8 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
newout:= output-$(shell date +%s)
oldout:= $(shell readlink www)

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 --no-times output-new/ output-current/

# atomically replace output symlink
ln -fsT output-current output-lnk
mv -T output-lnk output
rm -rf output-new
mv output $(newout)
ln -sfT $(newout) www
test -d $(oldout) && rm -rf $(oldout)

clean:
rm -rf output*
rm -rf output* www

deploy: all
# Publishing to http://hackerspace.sg.s3-website-ap-southeast-1.amazonaws.com/
# Assuming /var/www/s3cfg-secret with hsgweb credentials
s3cmd -P -c /var/www/s3cfg-secret -rr --delete-removed sync output/ s3://hackerspace.sg/
s3cmd -P -c /var/www/s3cfg-secret -rr --delete-removed sync www/ s3://hackerspace.sg/

.PHONY: all clean deploy
4 changes: 2 additions & 2 deletions apache/punch.hackerspace.sg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
ServerAdmin [email protected]
ServerName hackerspace.sg
ServerAlias punch.beta.hackerspace.sg
DocumentRoot /var/www/punch/output
<Directory /var/www/punch/output>
DocumentRoot /var/www/punch/www
<Directory /var/www/punch/www>
Options +FollowSymlinks +ExecCGI
AllowOverride All
</Directory>
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-new/.htaccess'));
fs.createReadStream('htaccess').pipe(fs.createWriteStream('output/.htaccess'));
}

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

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

0 comments on commit 5252d3a

Please sign in to comment.