]> git.openstreetmap.org Git - chef.git/commitdiff
Wrap DNS updates with a lock to avoid conflicts
authorTom Hughes <tom@compton.nu>
Thu, 18 Jun 2020 17:47:09 +0000 (18:47 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 18 Jun 2020 17:47:09 +0000 (18:47 +0100)
cookbooks/dns/recipes/default.rb
cookbooks/dns/templates/default/dns-check.erb
cookbooks/dns/templates/default/dns-update.erb

index 3f44b7fa0f36fb4bac517bbdc33ab8ae353da312..2f045a778bebed6ce262e5c940e489ef053bd834 100644 (file)
@@ -34,6 +34,7 @@ package %w[
   libyaml-libyaml-perl
   libwww-perl
   libjson-xs-perl
+  lockfile-progs
   sshfp
 ]
 
index 0c88edf428ca3eaadcb5cd3cf0b01fb72d990bef..00b97aa60d31e908973ef5ba3e8f35bd316a4bf4 100755 (executable)
@@ -5,4 +5,8 @@ export STATUSCAKE_USERNAME="OpenStreetMap"
 export STATUSCAKE_APIKEY="<%= @passwords["statuscake"] %>"
 export PATH=/usr/local/bin:$PATH
 
+lockfile-create --use-pid /var/lib/dns/update || exit 1
+
 make --quiet --jobs --directory=/var/lib/dns update > /dev/null
+
+lockfile-remove /var/lib/dns/update
index 4da924be048fcceec3208e5a1a137f33eb95c474..5353d69d42daa35841e7f0c3deb7a516af662250 100755 (executable)
@@ -11,6 +11,8 @@ export PATH=/usr/local/bin:$PATH
 
 cd /var/lib/dns
 
+lockfile-create --use-pid update || exit 1
+
 if [ ! -d .git ]
 then
   git clone /var/lib/git/public/dns.git /var/lib/dns
@@ -19,3 +21,5 @@ fi
 git pull -q
 
 make --jobs update
+
+lockfile-remove update