How can I start the capistrano task at a different stage?

My root capistrano has a task that drops a database: cap production dump

or cap staging dump

drops a database.

Now I want to define a task in stage that will run this task when it is created.

I could do

desc 'Updates the database of acceptance with the latest production database'
task :update_db do
  run_locally do
    execute :cap, 'production', 'dump'
    # move dump-file from production, via local, to acceptance
  end
  on roles(:db) do
    execute :rake, 'db:data:load'
  end
end

      

But executing the cap task from the cap task through the shell seems ugly and fragile.

I found Calling multistage capistrano task from capistrano task but that doesn't work, perhaps because its a solution for an older version of Capistrano.

Is there a way to run a specific capistrano task at a specific "stage", from within Capistrano?

+3


source to share





All Articles