Using Capistrano to deploy a Rails application to multiple web servers

后端 未结 3 741
日久生厌
日久生厌 2020-12-14 02:21

I\'m currently setting up a new production environment for a Rails application which includes multiple, load-balanced application servers (currently only two, but this will

相关标签:
3条回答
  • 2020-12-14 02:58

    Yeah. Capistrano manages multiple servers natively. No need for capistrano ext.
    You only need to define multiple roles

    role :app, "myserver.example.com"
    role :db,  "mysecondserver.example.com"
    

    By default your tasks will be executed on every server. But you can limit a task to one or some servers only.

    task :migrate, :roles => [:app, :db] do
        # ...
    end
    

    Here, the task will be executed only on the app and db roles.

    You can do the same with the run method.

    run "rake db:migrate", :roles => :db
    

    The rake db:migrate will be run only on the db server.

    0 讨论(0)
  • 2020-12-14 02:59

    Assuming capistrano multistage:

    In config/deploy/production:

    role :app, "server1", "server2", "server3"
    

    Now a cap deploy production will deploy to all 3 servers.

    0 讨论(0)
  • 2020-12-14 03:16

    This is what I have tried in rails 4:

    config/deploy.rb:

    role :app, %w{server1 server2 server3}
    
    0 讨论(0)
提交回复
热议问题