Skip to content

Commit

Permalink
use lock when rsyncing benchmarking data (#904)
Browse files Browse the repository at this point in the history
Fixes: #896
  • Loading branch information
rvagg authored Oct 10, 2017
1 parent 29bc6bc commit 10668d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
21 changes: 21 additions & 0 deletions setup/www/resources/scripts/sync-benchmarking.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

pidfile=/var/run/nodejs/sync-benchmarking.pid
cmd="
rsync -aqz --delete benchmark:charts/ /home/www/benchmarking/charts/ &&
rsync -aqz --delete benchmark:coverage-out/out/ /home/www/coverage/
"

if [ -a "$pidfile" -a -r "$pidfile" ]; then
read pid < "$pidfile"
if [ -n "${pid:-}" ]; then
if $(kill -0 "${pid:-}" 2> /dev/null); then
exit 0 # already running
# else stale pid
fi
fi
fi

echo $$ > $pidfile
bash -c "$cmd"
rm $pidfile
20 changes: 18 additions & 2 deletions setup/www/tasks/site-setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
group: root
tags: setup

- name: Site Setup | Copy sync-benchmarking.sh script
copy:
src: ./resources/scripts/sync-benchmarking.sh
dest: /home/nodejs/sync-benchmarking.sh
mode: 0755
owner: root
group: root
tags: setup

- name: Site Setup | Make /home/nodejs/.npm
file:
path: /home/nodejs/.npm
Expand All @@ -78,6 +87,14 @@
owner: nodejs
tags: setup

- name: Site Setup | Make /var/run/nodejs
file:
path: /var/run/nodejs
state: directory
mode: 0755
owner: nodejs
tags: setup

- name: Site Setup | Initial nodejs, iojs and benchmarking clone and update
become: yes
become_user: "nodejs"
Expand All @@ -98,6 +115,5 @@
- '* * * * * nodejs /home/nodejs/check-build-site.sh nodejs'
- '* * * * * nodejs /home/nodejs/check-build-site.sh iojs'
- '* * * * * root /home/nodejs/cdn-purge.sh'
- '* */4 * * * nodejs rsync -aqz --delete benchmark:charts/ /home/www/benchmarking/charts/'
- '* */4 * * * nodejs rsync -aqz --delete benchmark:coverage-out/out/ /home/www/coverage/'
- '* */4 * * * nodejs /home/nodejs/sync-benchmarking.sh'
tags: setup

0 comments on commit 10668d4

Please sign in to comment.