Late night capistrano

Excerpt from my current Capistrano cheat sheet:

cap deploy_with_migrations
- will deploy normally and then run 'rake db:migrate' (SCARY!)
- 'cap disable_web' (FIRST!)
- WILL NOT RUN ANY :after_deploy methods (FUCK!)

Now don’t get me wrong, I really love Capistrano (now at 1.4) as it makes my development life a lot easier. It’s just those little bits that bite you in the ass in the most unexpected moment.

Oh, and I’m sure there’s a reasonable explanation for this behaviour.

UPDATE: It has its own ticket now.

6 Responses to “Late night capistrano”

  1. Evan Says:

    i don’t think there’s a default after_deploy task even with the normal `cap deploy`. after_update_code sure, but after_deploy? after_migrate? those doesn’t exist out of the box. you can use after_update_code to do some more extra tasks after deploying, but what do you need to do after migration anyway?

  2. Paul Goscicki Says:

    Evan: there is no default “after_deploy” task. There is, however, a default “after_deploy” hook. You use it like that:

    task :after_deploy, :roles => :app do
      custom_functions
      (...)
    end
    

    What I was gripping about is that it does not get executed after deploy_with_migrations, which is kind of weird. Since I have important tasks executed at after_deploy I cannot use deploy_with_migrations as this code will not be executed.

  3. Luis de la Rosa Says:

    I just opened a ticket for this exact problem because it is causing me the same grief. The ticket is over at http://dev.rubyonrails.org/ticket/7897

    I’ll try to keep you updated. I have 3 solutions to this and waiting to hear back from Jamis or whomever wants to look into it before submitting a patch.

  4. Paul Goscicki Says:

    I’m glad to hear I’m not alone in my pain.

  5. Robertas Aganauskas Says:

    Just define :after_deploy_with_migrations task in your recipes file.

    There is one caveat (feature?) though: (at least for me) after_deploy_with_migrations seems not to be executed if cap_deploy_with_migrations task fails at some point. Other that it works just fine.

  6. Paul Goscicki Says:

    This is only a workaround that does not fix the described underlying problem.

Leave a Reply