Capistrano的 - 如何部署到多个云服务器 [英] Capistrano - How to deploy to multiple cloud servers

查看:174
本文介绍了Capistrano的 - 如何部署到多个云服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说Capistrano的支持部署到多台服务器,但我还没有找到一个切实可行的办法来进行设置。当我说多台服务器,我指运行在生产环境相同的应用程序服务器。在任何时候,我想将其部署到5或10台服务器,如果这是我目前使用的。

I've heard that Capistrano supports deployment to multiple servers, but I haven't found a practical way to set it up. When I say multiple servers I mean servers running the same application in a production environment. At any time I would like to deploy to 5 or 10 servers if that is what I'm currently using.

感谢你。

推荐答案

使用多台服务器是主要的原因之一使用Capistrano的对比只是在做事情的手。

Using multiple servers is one of the main reasons to use capistrano versus just doing things by hand.

您deploy.rb只需要定义哪些操作应该在什么服务器,这是通过设置完成哪些服务器属于哪个角色来执行。您可以创建自己的角色,但内置的Capistrano的食谱指望你定义3个角色:

Your deploy.rb just needs to define what actions should be performed on what servers, which is done by setting which servers belong to which roles. You can create your own roles, but the built-in capistrano recipes expect you to define 3 roles:

  • 应用程序:在您的应用程序code运行
  • 网络:网络前端
  • 分贝:其中迁移的运行

这并不少见,这3个是同义的:如果你有一堆相同的服务器上所有正在运行的Apache +乘客随后他们都是应用程序和Web服务器。其中一个需要给予的分贝作用

It's not uncommon for these 3 to be synonymous: if you have a bunch of identical servers all running apache + passenger then they are all app and web servers. One of them needs to be given the db role.

您在deploy.rb文件中定义的角色。在最简单的,这是IP地址或主机名只是一个列表:

You define roles in your deploy.rb file. At its simplest this is just a list of ip addresses or host names:

role :app, [192.168.1.1,192.168.1.2]

它也可以是一个块。例如,当部署到EC2你可能会插入一个API调用来检索服务器部署到列表中。我通常通过分配标签的服务器,在这种情况下,你可能做到这一点。

It can also be a block. For example when deploying to ec2 you might insert an api call that retrieves the list of servers to deploy to. I usually do this by assigning tags to servers, in which case you might have

role :app do
  ec2.instances.tagged('app').map(&:ip_address)
end

有这种角色映射与应用标签的EC2实例(Capistrano的缓存此信息,将只执行你的格挡一次)

to have that role map to the ec2 instances with the app tag (capistrano caches this information and will only execute your block once)

这篇关于Capistrano的 - 如何部署到多个云服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆