deploy.rb:
set :user, 'deploy'
set :domain, 'XX.XX.243.215'
set :application, 'saler'
# adjust if you are using RVM, remove if you are not
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, '1.9.3'
set :rvm_type, :user
# file paths
set :repository, "git@#{domain}:saler.git"
set :deploy_to, "/home/deploy/saler.com"
# distribute your applications across servers (the instructions below put them
# all on the same server, defined above as 'domain', adjust as necessary)
role :app, domain
role :web, domain
role :db, domain, :primary => true
# miscellaneous options
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false
set :rails_env, :production
namespace :deploy do
desc "cause Passenger to initiate a restart"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
end
end
after "deploy:update_code", :bundle_install
desc "install the necessary prerequisites"
task :bundle_install, :roles => :app do
run "cd #{release_path} && bundle install"
end
这个 deploy 文件都是参考 Agile_Web_Development_with_Rails_4th_for_Rails_3.2 的,然后初始化也是按照该书进行,首先执行:
$ cap deploy:setup
$ cap deploy:check
这两行都没有出问题,后面运行cap deploy:migrations
就报错了,错误如下:
$ cap deploy:migrations
* executing `deploy:migrations'
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote [email protected]:saler.git master"
command finished in 12446ms
* executing "if [ -d /home/deploy/saler.com/shared/cached-copy ]; then cd /home/deploy/saler.com/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard 8e8aa8f849a9438851a3767b338ab711d6470299 && git clean -d -x -f; else git clone [email protected]:saler.git /home/deploy/saler.com/shared/cached-copy && cd /home/deploy/saler.com/shared/cached-copy && git checkout -b deploy 8e8aa8f849a9438851a3767b338ab711d6470299; fi"
servers: ["XX.XX.243.215"]
[XX.XX.243.215] executing command
** [XX.XX.243.215 :: out] Cloning into /home/deploy/saler.com/shared/cached-copy...
** [XX.XX.243.215 :: err] Host key verification failed.
** [XX.XX.243.215 :: err] fatal: The remote end hung up unexpectedly
command finished in 2009ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'if [ -d /home/deploy/saler.com/shared/cached-copy ]; then cd /home/deploy/saler.com/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard 8e8aa8f849a9438851a3767b338ab711d6470299 && git clean -d -x -f; else git clone git@XX.XX.243.215:saler.git /home/deploy/saler.com/shared/cached-copy && cd /home/deploy/saler.com/shared/cached-copy && git checkout -b deploy 8e8aa8f849a9438851a3767b338ab711d6470299; fi'" on XX.XX.243.215
其中这里说的是 [XX.XX.243.215 :: err] Host key verification failed.可是我可以使用 SSH 登陆 VPS,而且前面两条命令也顺利执行,查了很多相关资料都没有提到是什么问题,请问有人遇过同样的问题吗?