Capistrano 多服务器:如何在部署过程中引用当前服务器?
一些背景知识,我运行的是 capistrino 2.9.0 和 capistrano-ext 1.2.1。多阶段部署正在按预期工作。与将服务器阵列添加到角色一样。
INSTANCES = ["this.server.com", "that.server.com"]
role(:web) {INSTANCES}
我一直在尝试使 :deploy_to 根据正在部署的服务器的名称生成一个路径,如下所示:
set :deploy_to, lambda { "/var/www/application/$HOSTNAME" }
这工作得很好,除了 this.server.com 和 that.server.com 实际上是同一主机。在此示例中,它没有根据我的deploy/stage.rb 文件中定义的服务器名称创建两个部署文件夹,而是仅生成一个 /var/www/application/server.com/
我一直在寻找一个 /var/www/application/server.com/方法可以在 capistrano 级别注入它或引用将保留这些详细信息的 shell 变量。似乎需要托管具有应用程序的多个实例的应用程序服务器是很常见的。
我真正需要的是:
set :deploy_to, lambda { "/var/www/application/$SERVER_NAME_CAP_IS_USING" }
Some background, I am capistrino running 2.9.0 and capistrano-ext 1.2.1. Multistage deployment is working as expected. As is adding arrays of server to the roles.
INSTANCES = ["this.server.com", "that.server.com"]
role(:web) {INSTANCES}
I've been trying to make :deploy_to produced a path based on the name of the server being deployed, like so:
set :deploy_to, lambda { "/var/www/application/$HOSTNAME" }
This is working pretty well, except this.server.com and that.server.com are actually the same host. In this example, instead of having two deploy folders based off the server names defined in my deploy/stage.rb file, it just produces the one /var/www/application/server.com/
I've been digging around looking for a way to either inject this at the capistrano level or reference a shell variable that would retain these details. It seems like needing to host an application server with multiple instances of an app would be common.
What I really need is:
set :deploy_to, lambda { "/var/www/application/$SERVER_NAME_CAP_IS_USING" }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这有帮助。您可以定义特定的 ServerDefinition 对象并根据任务或其他方式调用这些对象:
Maybe this helps. You can define specific ServerDefinition objects and call to those per task or whatever: