Capistrano进行分阶段和实时应用 [英] staging and live app with capistrano

查看:52
本文介绍了Capistrano进行分阶段和实时应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我会做一个简单但可能非常有用的事情,并创建另一个名为live的符号链接,该符号链接指向任意版本,并在当前通常位于顶部的位置保留当前电流:

I thought I'd do a simple yet potentially very useful thing, and create another symlink called live, that points to an arbitrary release, and leave current at the head where it usually is:

20120519235508 
20120521004833 
20120521024312 <-- live
20120521025150 
20120521030449 <-- current 

然后我将www.mysite.com配置为命中

I then configured www.mysite.com to hit

live/public 

和stage.mysite.com

and stage.mysite.com to hit

current/public

不幸的是,两个主机似乎都运行相同的应用程序,而不是两个不同的应用程序。我确认httpd.conf的设置正确,然后重新启动。但是,没有变化,它们都仍在运行同一个应用程序,确切地说,当前/公开引用的应用程序是这样。

Unfortunately both hosts seem to run the same app, and not 2 different apps. I've confirmed the httpd.conf has the correct settings and restarted it. However no change, they're both still running the same app, the app referenced by current/public to be exact.

我不知道我的设置是否错误,或者是否需要重新启动其他功能,或者这根本无法按照我的想象进行。我在用乘客。

I don't know if I have a setting wrong, or if something else needs to be restarted, or if this simply can't work as I imagined. I'm using passenger.

有人可以阐明这个问题吗,因为对于许多项目来说,这种配置对我来说非常有用。

Can someone shed some light on this subject, because this configuration would be VERY useful to me for many projects.

推荐答案

我建议使用多级扩展,而不是在releases目录中创建其他符号链接。使用此扩展,您可以定义不同的阶段并向其添加自定义配置。因此,不要在登台和生产中都使用一个部署目录,而要在彼此之间使用单独的目录。

Instead of creating an other symlink in the releases directory, I suggest to use the multistage extension. With this extension you can define different stages and add custom configuration to them. So instead of using one deployment directory for both staging and production, use a separate one for each other.

将以下几行添加到deploy.rb:

Add these lines to deploy.rb:

require "capistrano/ext/multistage"

set :stages, ["staging", "production"]
set :default_stage, "staging"

从deploy.rb中删除deploy_to变量。然后在config内部创建一个部署目录,其中包含带有阶段名称的文件。在这种情况下:deploy / staging.rb和deploy / production.rb。 staging.rb的内容:

Remove the deploy_to variable from deploy.rb. Then create a deploy directory inside config which has files with the stage names. In this case: deploy/staging.rb and deploy/production.rb. The content of staging.rb:

set :rails_env, "staging"
set :deploy_to, "staging/capistrano"

对于production.rb:

And similarly for production.rb:

set :rails_env, "production"
set :deploy_to, "production/capistrano"

当然可以更改deploy_to中的路径。然后将staging.example.com指向 staging / capistrano / current / public ,将www.example.com指向 production / capistrano / current / public

Of course change the paths in deploy_to. Then point staging.example.com to staging/capistrano/current/public and www.example.com to production/capistrano/current/public.

要执行暂存部署,请执行 cap暂存部署或简单的 cap deploy (请记住,在deploy.rb中将登台设置为默认设置),然后将 cap生产部署部署到生产中。

To do a staging deploy, execute cap staging deploy or simple cap deploy (remember, staging was set to default in deploy.rb) and cap production deploy to deploy to production.

这篇关于Capistrano进行分阶段和实时应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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