尝试将 rails 应用程序部署到远程服务器。
我不断收到此错误,无法理解如何解决此问题。
这是控制台日志:
D:\>cap deploy:migrations
* ←[32m2013-03-11 01:15:33 executing `deploy:migrations'←[0m
* ←[32m2013-03-11 01:15:33 executing `deploy:update_code'←[0m
updating the cached checkout on all servers
←[33mexecuting locally: "git ls-remote root@NNN.NNN.131.4:myAppName.git mast
er"←[0m
root@NNN.NNN.131.4's password:
←[2;37mcommand finished in 11708ms←[0m
* ←[33mexecuting "if [ -d /home/root/myAppName/shared/cached-copy ]; then cd /
home/root/myAppName/shared/cached-copy && git fetch origin && git fetch --tags
origin && git reset --hard eba696f2195d19adba5fc7730828a69e7bfc3e9d && git cle
an -d -x -f; else git clone root@NNN.NNN.131.4:myAppName.git /home/root/2antica
fe/shared/cached-copy && cd /home/root/myAppName/shared/cached-copy && git check
out -b deploy eba696f2195d19adba5fc7730828a69e7bfc3e9d; fi"←[0m
servers: ["NNN.NNN.131.4"]
Password:
[NNN.NNN.131.4] executing command
** [NNN.NNN.131.4 :: out] Cloning into '/home/root/myAppName/shared/cached-copy
'...
** [NNN.NNN.131.4 :: err] Host key verification failed.
** [NNN.NNN.131.4 :: err] fatal: The remote end hung up unexpectedly
←[2;37mcommand finished in 1171ms←[0m
failed: "sh -c 'if [ -d /home/root/myAppName/shared/cached-copy ]; then cd /home
/root/myAppName/shared/cached-copy && git fetch origin && git fetch --tags ori
gin && git reset --hard eba696f2195d19adba5fc7730828a69e7bfc3e9d && git clean
-d -x -f; else git clone root@NNN.NNN.131.4:myAppName.git /home/root/myAppName/s
hared/cached-copy && cd /home/root/myAppName/shared/cached-copy && git checkout
-b deploy eba696f2195d19adba5fc7730828a69e7bfc3e9d; fi'" on NNN.NNN.131.4
这是我的 deploy.rb:
require 'bundler/capistrano'
set :user, 'root'
set :domain, 'NNN.NNN.131.4'
set :application, 'myAppName'
set :repository, "#{user}@#{domain}:#{application}.git"
set :deploy_to, "/home/#{user}/myAppName"
role :app, domain
role :web, domain
role :db, domain, :primary => true
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
考虑到在 cap deploy:migrations 期间引发了错误,也许这是一个 db 错误?有什么问题?部署数据库是 mysql 5.5,在 database.yml 中正确提及。
编辑1:手动将存储库克隆到服务器。排除输出以节省空间。
编辑2:
将此添加到 deploy.rb:
default_run_options[:pty] = true
有一点帮助。该命令仍然失败,但留下更长的日志:
D:\>cap deploy:migrations
* ←[32m2013-03-11 02:24:54 executing `deploy:migrations'←[0m
* ←[32m2013-03-11 02:24:54 executing `deploy:update_code'←[0m
updating the cached checkout on all servers
←[33mexecuting locally: "git ls-remote root@NNN.NNN.131.4:myAppName.git mast
er"←[0m
root@NNN.NNN.131.4's password:
←[2;37mcommand finished in 12717ms←[0m
* ←[33mexecuting "if [ -d /home/root/myAppName/shared/cached-copy ]; then cd /
home/root/myAppName/shared/cached-copy && git fetch origin && git fetch --tags
origin && git reset --hard 8b6824f3750031076be93783d7d9f66f53b0b429 && git cle
an -d -x -f; else git clone root@NNN.NNN.131.4:myAppName.git /home/root/2antica
fe/shared/cached-copy && cd /home/root/myAppName/shared/cached-copy && git check
out -b deploy 8b6824f3750031076be93783d7d9f66f53b0b429; fi"←[0m
servers: ["NNN.NNN.131.4"]
Password:
[NNN.NNN.131.4] executing command
** [NNN.NNN.131.4 :: out] root@NNN.NNN.131.4's password:
Password:
** [NNN.NNN.131.4 :: out]
** [NNN.NNN.131.4 :: out] root@NNN.NNN.131.4's password:
Password:
** [NNN.NNN.131.4 :: out]
** [NNN.NNN.131.4 :: out] HEAD is now at 8b6824f capping capistrano
←[2;37mcommand finished in 23741ms←[0m
copying the cached version to /home/root/myAppName/releases/20130310222546
* ←[33mexecuting "cp -RPp /home/root/myAppName/shared/cached-copy /home/root/2
anticafe/releases/20130310222546 && (echo 8b6824f3750031076be93783d7d9f66f53b0b4
29 > /home/root/myAppName/releases/20130310222546/REVISION)"←[0m
servers: ["NNN.NNN.131.4"]
[NNN.NNN.131.4] executing command
←[2;37mcommand finished in 772ms←[0m
* ←[32m2013-03-11 02:25:47 executing `deploy:finalize_update'←[0m
* ←[33mexecuting "chmod -R -- g+w /home/root/myAppName/releases/20130310222546
&& rm -rf -- /home/root/myAppName/releases/20130310222546/public/system && mkdi
r -p -- /home/root/myAppName/releases/20130310222546/public/ && ln -s -- /home/r
oot/myAppName/shared/system /home/root/myAppName/releases/20130310222546/public/
system && rm -rf -- /home/root/myAppName/releases/20130310222546/log && ln -s --
/home/root/myAppName/shared/log /home/root/myAppName/releases/20130310222546/lo
g && rm -rf -- /home/root/myAppName/releases/20130310222546/tmp/pids && mkdir -p
-- /home/root/myAppName/releases/20130310222546/tmp/ && ln -s -- /home/root/2an
ticafe/shared/pids /home/root/myAppName/releases/20130310222546/tmp/pids"←[0m
servers: ["NNN.NNN.131.4"]
[NNN.NNN.131.4] executing command
←[2;37mcommand finished in 791ms←[0m
* ←[33mexecuting "find /home/root/myAppName/releases/20130310222546/public/ima
ges /home/root/myAppName/releases/20130310222546/public/stylesheets /home/root/2
anticafe/releases/20130310222546/public/javascripts -exec touch -t 201303102225.
48 -- {} ';'; true"←[0m
servers: ["NNN.NNN.131.4"]
[NNN.NNN.131.4] executing command
** [out :: NNN.NNN.131.4] find: `/home/root/myAppName/releases/20130310222546/p
ublic/images'
** [out :: NNN.NNN.131.4] : No such file or directory
** [out :: NNN.NNN.131.4] find: `/home/root/myAppName/releases/20130310222546/p
ublic/stylesheets'
** [out :: NNN.NNN.131.4] : No such file or directory
** [out :: NNN.NNN.131.4] find:
** [out :: NNN.NNN.131.4] `/home/root/myAppName/releases/20130310222546/public/
javascripts'
** [out :: NNN.NNN.131.4] : No such file or directory
←[2;37mcommand finished in 756ms←[0m
triggering after callbacks for `deploy:finalize_update'
* ←[32m2013-03-11 02:25:49 executing `bundle:install'←[0m
* ←[33mexecuting "ls -x /home/root/myAppName/releases"←[0m
servers: ["NNN.NNN.131.4"]
[NNN.NNN.131.4] executing command
←[2;37mcommand finished in 721ms←[0m
* ←[33mexecuting "cd /home/root/myAppName/releases/20130310222546 && bundle in
stall --gemfile /home/root/myAppName/releases/20130310222546/Gemfile --path /hom
e/root/myAppName/shared/bundle --deployment --quiet --without development test"←
[0m
servers: ["NNN.NNN.131.4"]
[NNN.NNN.131.4] executing command
** [out :: NNN.NNN.131.4] Cannot write a changed lockfile while frozen.
←[2;37mcommand finished in 10392ms←[0m
* ←[32m2013-03-11 02:26:00 executing `deploy:migrate'←[0m
* ←[33mexecuting "cd /home/root/myAppName/releases/20130310222546 && bundle ex
ec rake RAILS_ENV=production db:migrate"←[0m
servers: ["NNN.NNN.131.4"]
[NNN.NNN.131.4] executing command
** [out :: NNN.NNN.131.4] rake aborted!
** [out :: NNN.NNN.131.4] Please install the mysql2 adapter: `gem install activ
erecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it to Gemfile.)
** [out :: NNN.NNN.131.4] /var/lib/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/ru
bygems_integration.rb:205:in `block in replace_gem'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<
top (required)>'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
** [out :: NNN.NNN.131.4]
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_speci
fication.rb:48:in `resolve_hash_connection'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_speci
fication.rb:39:in `resolve_string_connection'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_speci
fication.rb:23:in `spec'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_speci
fication.rb:127:in `establish_connection'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/railtie.rb:76:in `block (2 levels) in <class:
Railtie>'
** [out :: NNN.NNN.131.4]
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tiverecord-3.2.1/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/initializable.rb:30:in `instance_exec'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/initializable.rb:30:in `run'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/initializable.rb:54:in `each'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/initializable.rb:54:in `run_initializers'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/application.rb:136:in `initialize!'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
** [out :: NNN.NNN.131.4]
** [out :: NNN.NNN.131.4] /home/root/myAppName/releases/20130310222546/config/e
nvironment.rb:5:in `<top (required)>'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ac
tivesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/application.rb:103:in `require_environment!'
** [out :: NNN.NNN.131.4] /home/root/myAppName/shared/bundle/ruby/1.9.1/gems/ra
ilties-3.2.1/lib/rails/application.rb:292:in `block (2 levels) in initialize_tas
ks'
** [out :: NNN.NNN.131.4]
** [out :: NNN.NNN.131.4] Tasks: TOP => db:migrate => environment
** [out :: NNN.NNN.131.4] (See full trace by running task with --trace)
←[2;37mcommand finished in 6856ms←[0m
failed: "sh -c 'cd /home/root/myAppName/releases/20130310222546 && bundle exec r
ake RAILS_ENV=production db:migrate'" on NNN.NNN.131.4
capistrano、mysql2 和 activerecord-mysql2-adapter 都在 gemfile 中。