Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some Capistrano deployment hooks not working

I am using Capistrano v2.14.2 and trying to use the before and after hooks for deploy:create_symlink, but none of them seem to firing...

I was getting this Warning:

[Deprecation Warning] This API has changed, please hook 'deploy:create_symlink' instead of 'deploy:symlink'.

So I updated my code to use deploy:create_symlink instead of deploy:symlink

Here is a snipplet of my deploy.rb

namespace :foo do
    task :start do
        puts "starting foo..."
    end

    task :stop do
        puts "stoping foo..."
    end
end

before('deploy:create_symlink', "foo:stop")
after('deploy:create_symlink', "foo:start")

Here is a snipplet of the output:

  * 2013-04-04 13:34:27 executing `deploy:symlink'
  * executing "rm -f /web/example.com/current && ln -s /web/example.com/releases/20130404203425 /web/example.com/current"
    servers: ["app1"]
    [app1] executing command
    command finished in 467ms

No hooks are called...

Hooks for deploy:finalize_update and deploy:update_code all seem to be working without any issue.

What has happened to being able to use before and after hooks for deploy:create_symlink ?

like image 368
Michael Avatar asked Apr 04 '13 20:04

Michael


2 Answers

I'm running into a similar issue, using the same version of Capistrano. I'm also using capistrano-multistage, and I'm curious if that is causing the issue some how (haven't tested a plain Capistrano setup yet).

Basically, if you hook into a before/after trigger on deploy:symlink, it tells you to use deploy:create_symlink, but deploy:symlink is what actually runs. If I trigger on either of those, it doesn't fire.

I ran across this article, which got me thinking that i should trigger on "after deploy" instead, since symlink is the last step in deploy for me:

http://blog.rememberlenny.com/2013/03/04/deploying-wordpress-with-capistrano-symlink-issue-fix/

Here is how I resolved my deployment:

  • Moved my "before deploy:symlink" trigger to "after deploy:finalize_update" (since that was the previous task and it actually triggers)
  • Moved my "after deploy:symlink" trigger to "after deploy"
like image 161
JesseP Avatar answered Sep 29 '22 18:09

JesseP


change

"after deploy:symlink"

to

"after deploy"
like image 24
edymerchk Avatar answered Sep 29 '22 16:09

edymerchk