From 0c9235ac82e96015a571f4fa6f8d0765e500c795 Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Fri, 30 Jan 2015 00:13:16 -0800 Subject: [PATCH] Quicly add file lock This is a quick fix to avoid other script from updating chef repo while bootstrap script is still running. I felt that I'd have a more configurable & elegant way to specify the file lock, but before I can find a better solution, let me just come up with this working solution. --- lib/stemcell/templates/bootstrap.sh.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/stemcell/templates/bootstrap.sh.erb b/lib/stemcell/templates/bootstrap.sh.erb index 49f28ec..7bc9a28 100755 --- a/lib/stemcell/templates/bootstrap.sh.erb +++ b/lib/stemcell/templates/bootstrap.sh.erb @@ -8,6 +8,11 @@ # Martin Rhoads +( +echo 'Acquiring converge lock...' +/usr/bin/flock -e 200 +echo 'Lock acquired!' + set -o pipefail PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin @@ -253,3 +258,4 @@ configure_chef_daemon echo "<%= last_bootstrap_line %>" +) 200> /var/run/converge.lock