开发者

Where do you set the IP address of the server to push the code to?

开发者 https://www.devze.com 2023-03-20 08:29 出处:网络
I\'m reading the capistrano tutorial: https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning

I'm reading the capistrano tutorial: https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning

Where do you set the i.p address of the server to push the code to?

Does it assume you have an SSH key setup?

What if you have 10 s开发者_Python百科ervers, is it best to use a different tool to mirror things?


Capistrano isn't responsible for pushing code (in the sense of pushing changes to SCM) you still do this with Git, or your other choice of SCM.

Capistrano by default will log onto the servers named in your "roles" and pull the code down from your source control, to each server individually.

If you have 10 servers, and they are all web servers, you would name them all in the web role in Capistrano.

There are excellent Github guides for more information, but in short, yes; it's expected that you have ssh keys setup for a) logging on to the servers as your deploy user, and b) for your server to reach the source control (often referred to as deploy keys.)

@Arthur's suggestion about capistrano multistage is useful only when deploying to multiple environments, such as "staging" and "production" where the procedure is the same, but the server list is different.


In your config/deploy.rb or Capfile, just set the "web" role to the IP Address you require as follows:

role :web, "1.2.3.4", "5.6.7.8"

As mentioned by others, you will need to setup SSH keys (unless you really like typing passwords!) and then when you type cap deploy it will (depending on your settings) either checkout the git repo, tarball it and scp the tarball to the server (:deploy_via :copy or :deploy_via :export) or ssh to the server and check out the git repo directly (the default behaviour).


Take a look at capistrano multistage extension. Works well with multiple servers. You would then define different stages (or servers) in separate files and then deploy to each one by specifying the stage (and you may have a default stage to deploy to).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号