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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With