Capistrano 任务未在给定范围内执行。
我已经构建了一些需要在定义的 :app
角色中运行的 capistrano 任务。这是我到目前为止所拥有的:
desc "Stop unicorn"
task :stop, :roles => :app do
logger.info "Stopping unicorn server(s).."
run "touch #{unicorn_pid}"
pid = capture("cat #{unicorn_pid}").to_i
run "kill -s QUIT #{pid}" if pid > 0
end
据我所知,这应该在 :app
角色中给定的服务器上运行给定的命令,对吧?但事实是它以 :db
角色在服务器上运行命令。
任何人都可以深入了解这个问题吗?或者有没有办法强制 Capistrano 遵守 :roles
标志?
提前致谢
//埃米尔
I have build some capistrano tasks which I need to run on within the defined :app
roles. This is what I have so far:
desc "Stop unicorn"
task :stop, :roles => :app do
logger.info "Stopping unicorn server(s).."
run "touch #{unicorn_pid}"
pid = capture("cat #{unicorn_pid}").to_i
run "kill -s QUIT #{pid}" if pid > 0
end
As far as I know, this should run the given commands on the servers given in the :app
role, right? But the fact of the matter is that it's running the commands on the servers in the :db
role.
Can anyone give some insight into this problem? Or is there a way to force Capistrano to adhere to the :roles
flag?
Thanks in advance
// Emil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Capture 将导致任务仅在列出的第一台服务器上运行。
从文档中:
捕获助手将在第一个匹配的服务器上执行给定的命令,并将命令的输出作为字符串返回。
https://github.com/capistrano/capistrano/wiki /2.x-DSL-Action-Inspection-Capture
不幸的是,我面临着类似的问题,find_servers解决方案可能有效,但它很hacky,并且运行N x N次,其中N在您拥有的服务器数量。
Using Capture will cause the task to be run only on the first server listed.
From the documentation:
The capture helper will execute the given command on the first matching server, and will return the output of the command as a string.
https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-Inspection-Capture
Unfortunately I am facing a similar issue, the find_servers solution may work, but it's hacky, and runs N x N times, where N in the number of servers you have.