10

我正在使用Capistrano v2.14.2并尝试使用beforeandafter钩子deploy:create_symlink,但它们似乎都没有触发......

我收到了这个警告:

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

所以我更新了我的代码以使用deploy:create_symlink而不是deploy:symlink

这是我的一个片段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")

这是输出的片段:

  * 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

没有钩子被称为...

Hooks for deploy:finalize_updateand deploy:update_codeall 似乎都在正常工作,没有任何问题。

能够使用beforeafter钩子发生了deploy:create_symlink什么?

4

2 回答 2

5

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"
于 2013-04-10T20:06:53.173 回答
3

改变

"after deploy:symlink"

"after deploy"
于 2014-01-07T15:28:43.067 回答