I am using Ruby on Rails 3.0.9 and I trying to setup the Capistrano gem (following the Agile Web Development with Rails book - Fourth Edition). I setup git and all related directories\files on the remote machine (it works) and all "basic" things related to Capistrano. Now if I run from my local machine the following commands those work as expected:
cap deploy:setup
# ...
cap deploy:check
# ...
# You appear to have all necessary dependencies installed
At this time on the server machine in my project directory I have the following directories (created by Capistrano):
<my_project_dir>/releases
<my_project_dir>/shared
Nothing more.
What I should do now? For example, have I to upload all my application file from my local machine to the remote machine?
P.S.: I also setup my Apache2 server to point to the <my_project_dir>/current/public
directory but Capistrano didn't create that folder.
UPDATE for @Alex
If I run the cap deploy
command I get the following:
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote root@<SERVER_IP_ADDRESS>:/git/<my_project_name>.com.git master"
command finished in 3086ms
* executing "if [ -d /srv/www/<my_project_name>.com/shared/cached-copy ]; then cd /srv/www/<my_project_name>.com/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 36ccf7b6f63041ee8dcdf4ca0a7c0b10dbc8bad1 && git clean -q -d -x -f; else git clone -q root@<SERVER_IP_ADDRESS>:/git/<my_project_name>.com.git /srv/www/<my_project_name>.com/shared/cached-copy && cd /srv/www/<my_project_name>.com/shared/cached-copy && git checkout -q -b deploy 36ccf7b6f63041ee8dcdf4ca0a7c0b10dbc8bad1; fi"
serve开发者_JS百科rs: ["<SERVER_IP_ADDRESS>"]
[<SERVER_IP_ADDRESS>] executing command
** [<SERVER_IP_ADDRESS> :: err] Host key verification failed.
** [<SERVER_IP_ADDRESS> :: err] fatal: The remote end hung up unexpectedly
command finished in 396ms
*** [deploy:update_code] rolling back
* executing "rm -rf /srv/www/<my_project_name>.com/releases/20110820175634; true"
servers: ["<SERVER_IP_ADDRESS>"]
[<SERVER_IP_ADDRESS>] executing command
command finished in 353ms
failed: "sh -c 'if [ -d /srv/www/<my_project_name>.com/shared/cached-copy ]; then cd /srv/www/<my_project_name>.com/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 36ccf7b6f63041ee8dcdf4ca0a7c0b10dbc8bad1 && git clean -q -d -x -f; else git clone -q root@<SERVER_IP_ADDRESS>:/git/<my_project_name>.com.git /srv/www/<my_project_name>.com/shared/cached-copy && cd /srv/www/<my_project_name>.com/shared/cached-copy && git checkout -q -b deploy 36ccf7b6f63041ee8dcdf4ca0a7c0b10dbc8bad1; fi'" on <SERVER_IP_ADDRESS>
Note: failed: ...
on the last line. What is the problem?
Because your git repo is on the deployment server itself, Capistrano has same difficulties. Simply set the deploy_via
variable to :copy
in your deploy.rb
to fix:
set deploy_via :copy
[<SERVER_IP_ADDRESS>] executing command
** [ :: err] Host key verification failed. ** [ :: err] fatal: The remote end hung up unexpectedly
In my case, this was caused by having my git repo set up with an ssh URL.
I was able to solve this issue by logging into the host via ssh, then executing 'ssh ', then accepting the host key.
You can do a couple of things:
- cap deploy:setup This will setup any dirs, symlinks, etc that capistrano needs
- cap deploy:check This will make sure everything is set up for cap
- cap deploy:cold This deploys and starts up all the configured daemons (eg mongrel, apache, whatever you're using)
You have to perform cap deploy:cold
for the first time and then onwards use cap deploy
or cap deploy:migrations
to deploy the app.
These commands can either copy the code to the production server from local machine or even from the remote git repository.
Look at the configuration options here: http://help.github.com/deploy-with-capistrano/
The above commands will also create the symlink <my_project_dir>/current
for you
The above error indicates that your server is not able to clone the git repository from github. Generate a SSK key pair in the server machine using app user and upload the public key to the github deploy keys..
精彩评论