2010-11-10 72 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