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有兩個不同的值?它是否是範圍問題?我已經嘗試過使用全球($),但這並不奏效。