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

回答

0

解決了這個問題,只是通過從使用:主機更改爲:應用程序特定任務上的角色並添加了新角色。關鍵特性是使用no_release,以便代碼不會部署到應用程序服務器。我們只想在這些機器上重新啓動樹脂實例。

task :production do 
    role :nfs, "nfs.someserver.net" 
    role :application, "app.someserver.net", :no_release => true; 
end 

task :staging do 
    role :nfs, "nfs-staging.someserver.net" 
    role :application, "app-staging.someserver.net", :no_release => true; 
end 

desc "tail resin logs #{resin_logs}" 
task :tail, :roles => application_servers do 
    puts("Server is:"#{application_servers}) 
    stream "tail -f #{resin_logs}" 
end