在Windows上使用capistrano与本地存储库进行部署会引发错误

时间:2011-02-21 12:31:54

标签: ruby-on-rails windows git capistrano

要使Capistrano工作,存储库是否必须可以访问外部?

我在我的git存储库所在的本地目录中开发了一个rails应用程序。

我经常这样做:

git add .
git commit -am "it works after my recent changes"

现在我想部署:

cap deploy

但是这给了我这个错误信息(路径略有改变):

  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote D:\\path\\to\\railsapp\\.git HEAD"
  * executing "git clone  D:\\path\\to\\railsapp\\.git /home/user/railsapp/releases/20110221122258 && cd /home/user/railsapp/releases/20110221122258 && git checkout  -b deploy 70426fc8c8e81dff69f3ebf667de4f91dbd90119 && (echo 70426fc8c8e81dff69f3ebf667de4f91dbd90119 > /home/user/railsapp/releases/20110221122258/REVISION)"
    servers: ["my.server.tld"]
    [my.server.tld] executing command
 ** [my.server.tld :: out] Initialized empty Git repository in /home/user/railsapp/releases/20110221122258/.git/
 ** [my.server.tld :: out] Error reading response length from authentication socket.
 ** [my.server.tld :: out] Permission denied (publickey).
 ** fatal: The remote end hung up unexpectedly    command finished
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/user/railsapp/releases/20110221122258; true"
    servers: ["my.server.tld"]
    [my.server.tld] executing command
    command finished
failed: "sh -c 'git clone  D:\\path\\to\\railsapp\\.git /home/user/railsapp/releases/20110221122258 && cd /home/user/railsapp/releases/20110221122258 && git checkout  -b deploy 70426fc8c8e81dff69f3ebf667de4f91dbd90119&& (echo 70426fc8c8e81dff69f3ebf667de4f91dbd90119 > /home/user/railsapp/releases/20110221122258/REVISION)'" on my.server.tld

我做错了什么?

我在deploy.rb

require 'bundler/capistrano'
set :user, "username"
set :password, "password"
set :ssh_options, { :forward_agent => true }
set :application, "railsapp"
set :repository, "D:\\path\\to\\railsapp\\.git"
set :scm, :git
set :scm_verbose, true
default_run_options[:pty] = true
set :use_sudo, false
set :deploy_to, "/home/#{user}/#{application}"
role :app, "my.domain.tld"
role :web, "my.domain.tld"
role :db,  "my.domain.tld", :primary => true

namespace :deploy do

  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  desc "Additional Symlinks ( database.yml, etc. )"
  task :additional_symlink, :roles => :app do
    run "ln -s #{shared_path}/config/database.yml #{current_path}/config/database.yml"
  end

end
after "deploy:symlink","deploy:additional_symlink","deploy:migrate"

3 个答案:

答案 0 :(得分:0)

您的服务器需要能够访问托管代码的存储库。现在它在尝试检查代码时失败了,因为它没有被授权访问本地机器。

我建议在Github上托管存储库(如果您不介意源是公开的,则免费)。

您还可以在服务器上设置一个git存储库作为远程主机,并从那里推送本地存储库中的更改。然后配置capistrano以在部署时查找该存储库。

如果没有意义,请高兴地详细说明。

答案 1 :(得分:0)

my.domain.tld更改为localhost或远程服务器的网址

答案 2 :(得分:0)

我认为您需要更改部署策略以复制:

 set :deploy_via, :copy