Skip to content

Instantly share code, notes, and snippets.

@stojg
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stojg/72d52f2e115cd55bbff4 to your computer and use it in GitHub Desktop.
Save stojg/72d52f2e115cd55bbff4 to your computer and use it in GitHub Desktop.
--- a/cwp/files/repos/deploynaut-lib/cwptasks.rb
+++ b/cwp/files/repos/deploynaut-lib/cwptasks.rb
@@ -5,26 +5,9 @@ namespace :deploy do
# We are deploying to both sides, signal to csync2 that we want it disabled, and wait for it to finish.
task :disable_csync do
run "touch #{deploy_to}/csync2.disable"
-
- # Check lock by trying to acquire it for one minute (36 checks, 5s delay).
- # Outer bash is needed for the loop to function correctly.
- begin
- run <<ACQUIRELOCK
- bash -c "\
- for i in {1..36}; do\
- if flock -n -e /var/run/csync2.lock -c 'true'; then exit 0; fi;\
- echo 'Waiting for current file sync to finish...';\
- sleep 5;\
- done;\
- echo 'Timed out. Please try again later.';\
- exit 1\
- "
-ACQUIRELOCK
- rescue Exception => e
- run "rm #{deploy_to}/csync2.disable"
- raise e
- end
-
+ # Unfortunately we have to kill all running csync2 scripts and wrapper otherwise they can block the deployment for longer than
+ # we can reasonable wait for it to finish, see #CWP-184
+ run "/bin/pidof /usr/sbin/csync2 && sudo /usr/bin/killall -w /usr/sbin/csync2; true"
end
--- a/cwp/manifests/instance.pp
+++ b/cwp/manifests/instance.pp
@@ -63,7 +63,7 @@ class cwp::instance {
# We are still using $hostname as the username, no need to distinguis between dr and not.
sudo::conf { $hostname:
priority => 10,
- content => "${hostname} ALL=(www-data) NOPASSWD:ALL"
+ content => "${hostname} ALL=(www-data) NOPASSWD:ALL\n${hostname} ALL=(ALL) NOPASSWD: /usr/bin/killall -w /usr/sbin/csync2"
}
# Make the server known to the other servers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment