4

Upgrading to capistrano 3, the following no longer seems to work:

namespace :project do
  desc "Prevents executing by creating lockfile"
  task :disable do
    on roles(:app) do
      execute "touch /tmp/proj_lockfile"
    end
    on_rollback do
      execute "rm /tmp/proj_lockfile"
    end
  end
end

...
NoMethodError: undefined method `on_rollback' for main:Object
config/deploy.rb:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => deploy:starting => transformer:disable
(See full trace by running task with --trace)

Is there a new task etc to do this?

Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130

2 Answers2

5

There is no Capistrano 3 equivalent of on_rollback.

In Capistrano 3, if any command fails, the deployment stops, and the release that was being deployed is left in place (possibly working and deployed, possibly not working and deployed, or not deployed - Capistrano no longer attempts to clean up at all).

Note that this also means that :on_error => :continue is unsupported with no replacement; you have to begin/rescue any exceptions yourself.

The rollbacks section of the documentation is completely empty.

Dominic Scheirlinck
  • 2,627
  • 2
  • 23
  • 28
-2

Take a look at the "Rollback flow" documentation: http://capistranorb.com/documentation/getting-started/flow/

deploy:starting
deploy:started
deploy:reverting           - revert server(s) to previous release
deploy:reverted            - reverted hook
deploy:publishing
deploy:published
deploy:finishing_rollback  - finish the rollback, clean up everything
deploy:finished
Joe
  • 2,987
  • 15
  • 24
  • That's just the flow for `deploy:rollback` - it's completely different from `on_rollback` in Cap2, which occurs when a normal deploy task fails (not when the user is trying to roll back a whole deploy) – Dominic Scheirlinck Feb 23 '15 at 21:39