Production and live application with capistrano

I thought I would do a simple but potentially very useful thing, and create another symbolic link called live, which points to an arbitrary version and leaves the current at the beginning, where it usually is:

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

Then I set up www.mysite.com to click

 live/public 

and stage.mysite.com click

 current/public 

Unfortunately, both hosts seem to be running the same application, not 2 different applications. I confirmed that httpd.conf has the correct settings and restarted it. However, no changes, they both still work with the same application, and the application referenced by the current / public one will be accurate.

I don’t know if I have the wrong setting or if something else needs to be restarted, or if it just cannot work, as I imagined. I use a passenger.

Can someone shed light on this topic, because this configuration would be very useful for many projects.

+5
source share
1 answer

Instead of creating another symbolic link in the release catalog, I suggest using a multi-stage extension. With this extension, you can define different steps and add a custom configuration to them. Therefore, instead of using one deployment directory for production 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 deployment directory inside the configuration that contains files with scene names. In this case: deploy / staging.rb and deploy / production.rb. Contents 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 send staging.example.com to staging/capistrano/current/public and www.example.com to production/capistrano/current/public .

To deploy the intermediate version, run cap staging deploy or just cap deploy (remember that the installation was installed by default in deploy.rb) and cap production deploy to deploy to production.

+12
source

Source: https://habr.com/ru/post/923101/


All Articles