我有一个rails 3.2应用程序已经使用capistrano v2部署到我的舞台&生产服务器快乐一年。现在我正在尝试升级到capistrano v3而且我遇到了这个问题;
INFO[2f0d4d3d] Running /usr/bin/env git remote update on staging.pais.com.au
DEBUG[2f0d4d3d] Command: cd /srv/pais/repo && ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/pais/git-ssh.sh /usr/bin/env git remote update )
DEBUG[2f0d4d3d] Fetching origin
DEBUG[2f0d4d3d] Fetching origin
DEBUG[2f0d4d3d] error: Could not fetch origin
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host staging.pais.com.au: git exit status: 1
git stdout: Nothing written
git stderr: error: Could not fetch origin
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/git.rb:11:in `git'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/git.rb:29:in `update'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:53:in `block (5 levels) in <top (required)>'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:52:in `block (4 levels) in <top (required)>'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in `within'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/tasks/git.rake:51:in `block (3 levels) in <top (required)>'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/usr/local/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SSHKit::Command::Failed: git exit status: 1
git stdout: Nothing written
git stderr: error: Could not fetch origin
这是我的deploy.rb
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, "pais"
# Version control system
set :scm, :git
set :repo_url, "map7@192.168.200.4:/home/map7/pais"
set :branch, "master"
set :git_enable_submodules, 1 # Get submodules
set :git_submodules_recursive, true
# Remote user info
set :user, "map7" # 'vps' is the default MammothVPS user
set :use_sudo, false
# RBENV setup
set :rbenv_ruby, "2.1.1"
set :rbenv_path, "/usr/local/rbenv"
bundle_path = "/usr/local/rbenv/shims/bundle"
# Setup stages
set :stages, ["staging", "production"]
set :default_stage, "staging"
# Default deploy_to directory is /var/www/my_app
set :deploy_to, "/srv/pais"
# Default value for keep_releases is 5
set :keep_releases, 5
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
这是我的deploy / staging.rb
server 'staging.pais.com.au', user: 'map7', roles: %w{web app db}, :primary => true
它正在创建/ srv / pais / repo目录,它有一个原点集。我可以使用密钥从登台服务器ssh到我的开发机器而无需密码。
答案 0 :(得分:1)
这一行error: Could not fetch origin
指出了一个连接到你的git repo的问题。
deploy.rb
的git网址应以.git
结尾。所以,像:
set :repo_url, "map7@192.168.200.4:/home/map7/pais.git"
另外,请仔细检查您的git仓库的其余路径是否正确,以及您确实ssh访问托管git仓库的服务器。