0
我有一个用于Multistage部署的Capfile,需要将代码部署到一台服务器(NFS)并最终重新启动多个应用程序服务器。因此,角色无法轻松使用,因为应用程序服务器不需要用于部署:update_code。我想出了一些可能有用的东西,但有一个问题需要解决。问题发生在:主机
#$ cap staging tail
* executing `staging'
* executing `tail'
Server is:app-staging.someserver.net
* executing "tail -f /log/resin/*.log"
servers: ["nfs-staging.someserver.net"]
[nfs-staging.someserver.net] executing command
tail: cannot open `/log/resin/*.log' for reading: No such file or directory
tail: no files remaining
command finished
failed: "sh -c 'tail -f /log/resin/*.log'" on nfs-staging.someserver.net
当打印在任务尾application_servers的值它说 “app-staging.someserver.net”,但在所使用的值::主机=> application_servers是空
application_servers = nil
task :production do
role :nfs, "nfs.someserver.net"
application_servers = "app.someserver.net"
end
task :staging do
role :nfs, "nfs-staging.someserver.net"
application_servers = "app-staging.someserver.net"
end
desc "tail resin logs #{resin_logs}"
task :tail, :hosts => application_servers do
puts("Server is:"#{application_servers})
stream "tail -f #{resin_logs}"
end
运行时
而(这就是它使用nfs角色的原因)。
为什么变量application_server有两个不同的值?它是否是范围问题?我已经尝试过使用全球($),但这并不奏效。