一些Capistrano部署挂钩无法正常工作

时间:2023-02-01 07:47:03

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...

我正在使用Capistrano v2.14.2并尝试使用前缀和后续钩子进行部署:create_symlink,但它们似乎都没有触发......

I was getting this Warning:

我收到了这个警告:

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

[弃用警告]此API已更改,请挂钩'deploy:create_symlink'而不是'deploy:symlink'。

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

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

Here is a snipplet of my deploy.rb

这是我的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.

用于部署的钩子:finalize_update和deploy:update_code似乎都没有任何问题。

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

在部署钩子之前和之后能够使用的是什么:create_symlink?

2 个解决方案

#1


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).

我遇到了类似的问题,使用相同版本的Capistrano。我也使用capistrano-multistage,我很好奇,如果这导致问题的一些方法(尚未测试普通的Capistrano设置)。

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.

基本上,如果你在deploy:symlink上挂钩到before / after触发器,它会告诉你使用deploy:create_symlink,但是deploy:symlink是实际运行的。如果我触发其中任何一个,它就不会触发。

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/

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)
  • 将我的“部署前:符号链接”触发器移动到“部署后:finalize_update”(因为那是上一个任务,它实际上触发了)
  • Moved my "after deploy:symlink" trigger to "after deploy"
  • 将我的“部署后:符号链接”触发器移动到“部署后”

#2


3  

change

更改

"after deploy:symlink"

to

"after deploy"

#1


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).

我遇到了类似的问题,使用相同版本的Capistrano。我也使用capistrano-multistage,我很好奇,如果这导致问题的一些方法(尚未测试普通的Capistrano设置)。

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.

基本上,如果你在deploy:symlink上挂钩到before / after触发器,它会告诉你使用deploy:create_symlink,但是deploy:symlink是实际运行的。如果我触发其中任何一个,它就不会触发。

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/

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)
  • 将我的“部署前:符号链接”触发器移动到“部署后:finalize_update”(因为那是上一个任务,它实际上触发了)
  • Moved my "after deploy:symlink" trigger to "after deploy"
  • 将我的“部署后:符号链接”触发器移动到“部署后”

#2


3  

change

更改

"after deploy:symlink"

to

"after deploy"