We're using Webistrano to deploy our Drupal sites to testing and production.

The recipe we're using is as follows:

namespace :drupal do
  desc "symlink_files"
  task :symlink_files do
    invoke_command "ln -s #{deploy_to}/shared/files #{deploy_to}/current/drupal/sites/default/"
    invoke_command "ln -s #{deploy_to}/shared/settings.php #{deploy_to}/current/drupal/sites/default/"

  desc "refresh_configuration"
  task :refresh_configuration do
    invoke_command "cd #{deploy_to}/current/drupal; drush #{drush_options} -y fr-all"
    invoke_command "cd #{deploy_to}/current/drupal; drush #{drush_options} -y updb"
    invoke_command "cd #{deploy_to}/current/drupal; drush #{drush_options} cc all"

after 'deploy:symlink','drupal:symlink_files','drupal:refresh_configuration'

This method is working great for single-host deployments, but fails for multi-host deployments. The reason is that the refresh_configuration task will run on each host, causing all kinds of race conditions and corruption on the central database server.

My question is, can anyone suggest a way to fix the Webistrano setup to only run refresh_configuration task on one server only?

PS. I'm not interested in changing the deployment system to Aegir or anything else.

  • Do you have any error, are you sure that every host has the same architecture ? – yvan Mar 20 '12 at 7:06
  • Yes, all hosts have the same architecture. Surprisingly, there is no error that I could find in the deployment log. The recipe fails (with multiple hosts only) at the invocation of drush updb. – infojunkie Mar 20 '12 at 16:04
  • If you are interested we made a recipe than should work on multiple server antistatique.github.io/capdrupal – gagarine Jun 26 '13 at 13:37

As per this Capistrano Wiki page, you can restrict tasks and single commands to specific :roles and :only attributes:

task :migrate, :roles => :db, :only => { :master => true } do
  # ...

task :other do
  run "migrate", :roles => :db, :only => { :master => true }

Using this, I was able to run the refresh_configuration task to run on a server with a specific attribute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.