When you define a task in Capistrano, you can restrict the task to a specific role. How do you do this by passing the :role parameter.
It seems the default delayed_job Capistrano recipe does this.
desc "Stop the delayed_job process" task :stop, :roles => lambda { roles } do run "cd #{current_path};#{rails_env} script/delayed_job stop" end
According to the source code, the task retrieves the list of roles from the configuration variable :delayed_job_server_role .
Let's get back to your problem in order to narrow down the execution of tasks to a specific group of servers, to define a new role (for example, a worker) in deploy.rb
role :worker, "192.168.1.1"
Then set :delayed_job_server_role to this name
set :delayed_job_server_role, :worker
It's all. Now the tasks will be completed, but only for the servers listed in the role :worker .
Simone carletti
source share