2

I have a webserver cluster with two nodes. They use the same file server to host files from. Since the files are shared, I only need to get to one of the servers to do my deploy, but I would like to clear APC cache on both of them. Is there a way for me to tell Capifony to not deploy to the second server, just run "symfony:clear_apc"?

My deploy.rb as it currently stands:

set :application, "app.domain.net"
set :domain,      "#{application}"
set :deploy_to,   "/hosting_files/#{application}"
set :app_path,    "app"
set :web_path,    "web"

set :repository,  "git@bitbucket.org:company/#{application}.git"
set :scm,         :git
set :deploy_via,  :remote_cache

set :model_manager, "doctrine"

role :web,        "X.domain.com"
role :app,        "X.domain.com"
role :db,         "X.domain.com", :primary => true

set :keep_releases,  10
set :shared_files,      ["app/config/parameters.yml"]
set :shared_children,   [app_path + "/logs", web_path + "/uploads", "vendor"]
set :permission_method, :acl
set :use_composer,      true

set :interactive_mode,  false
set :branch, `git tag`.split("\n").last

set :user,  "applicationUser"
set :use_sudo, false
ssh_options[:forward_agent] = true
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "id_rsa")]

"symfony:cache:warmup"

logger.level = Logger::MAX_LEVEL

namespace :symfony do
  desc "Clear apc cache"
  task :clear_apc do
    capifony_pretty_print "--> Clear apc cache"
    run "php #{deploy_to}/current/app/console apc:clear"
    capifony_puts_ok
  end
end

after "deploy", "symfony:clear_apc"
nwalke
  • 3,170
  • 6
  • 35
  • 60

1 Answers1

2

You should use the multistage extension, to configure access parameters for both of your nodes: http://capifony.org/cookbook/using-the-multistage-extension.html

Create deployment configurations node1 and node2. You will be able to deploy your files to any of the nodes. Even better, set one of the nodes as a default stage with

set :default_stage "node1"

After that you will be able to execute symfony commands on each of the servers separately by adding the stage(node) name after the cap command:

cap node2 symfony:clear_apc
georgelx
  • 474
  • 3
  • 9