staging and live app with capistrano

老子叫甜甜 提交于 2019-12-04 07:40:24

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.

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