Deploying a Rails App to Multiple Servers using Capistrano - Best Practices

前端 未结 2 1861
情歌与酒
情歌与酒 2020-12-02 06:02

I have a rails application that I need to deploy to 3 servers - machine1.com, machine2.com and machine3.com. I want to be able to deploy it to all machines at once and each

相关标签:
2条回答
  • 2020-12-02 06:49

    I had to use a slightly different syntax.

    role :app, %w{s01.foobaz.com s02.foobaz.com}, user: 'deployer'
    role :web, %w{s01.foobaz.com s02.foobaz.com}, user: 'deployer'
    
    0 讨论(0)
  • 2020-12-02 06:53

    It should all go in one file. Here's an example:

    set :application, "my-app"
    set :repository,  "git@git.my-git-host.com:my-app.git"
    set :keep_releases, 5
    set :deploy_via, :remote_cache
    set :git_enable_submodules, true
    set :scm, :git
    set :user, 'your-user-here'
    
    set :deploy_to, "/var/www/staging.mydomain.com"
    set :branch, 'staging'
    set :rails_env, 'staging'
    
    role :web, "machine1.mydomain.com", "machine2.mydomain.com", "machine3.mydomain.com"
    role :app, "machine1.mydomain.com", "machine2.mydomain.com", "machine3.mydomain.com"
    role :db, "db.mydomain.com"
    # ...
    

    You'll see that only one db server was specified. This is the machine the migrations will be run from. If you only have one database (99.9% chance of the answer to that question being YES), then make sure to only provide one.

    0 讨论(0)
提交回复
热议问题