简体   繁体   English

Capistrano 3在钩子之前和之后

[英]Capistrano 3 Before and After Hooks

I just switched to using Capistrano 3 and ran into some issues with the before and after hooks documentation. 我刚刚切换到使用Capistrano 3并遇到了前后钩子文档的一些问题。

In the docs it show the following for calling existing tasks 在文档中,它显示以下内容用于调用现有任务

before :starting, :ensure_user
after :finishing, :notify

If I use this syntax I get 'Don't know how to build task starting' Instead I had to do the following to get my tasks to work. 如果我使用这种语法,我会得到“不知道如何构建任务的开始”而是我必须执行以下操作才能使我的任务正常工作。

before "deploy:starting", "dj:stop"
after "deploy:finished", "dj:start"

The dj tasks are in Capistrano tasks directory in a *.rake file. dj任务位于* .rake文件中的Capistrano任务目录中。 Any ideas on what I may be missing or do the docs need to be updated? 关于我可能缺少什么或做文档的任何想法都需要更新?

Ruby 2.1.6 Rails 4.2.0 Capistrano 3.4.0 Ruby 2.1.6 Rails 4.2.0 Capistrano 3.4.0

You can only use the shortcut version ( before :starting, :ensure_user ) when both tasks are inside the same namespace. 当两个任务都在同一名称空间内时before :starting, :ensure_user您只能使用快捷方式版本( before :starting, :ensure_user )。 When you want to execute tasks from different namespaces, you need to include the namespace inside the string ( before "deploy:starting", "dj:stop" ). 如果要从不同的命名空间执行任务,则需要在字符串中包含命名空间( before "deploy:starting", "dj:stop" )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM