staging and live app with capistrano

十年热恋 提交于 2019-12-06 02:32:53

问题


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 

I then configured www.mysite.com to hit

live/public 

and stage.mysite.com to hit

current/public

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.


回答1:


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.

Add these lines to deploy.rb:

require "capistrano/ext/multistage"

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

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"

And similarly for production.rb:

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

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.

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.



来源:https://stackoverflow.com/questions/10679455/staging-and-live-app-with-capistrano

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!