开发者

Deploying with capistrano with local repository on windows throws error

For Capistrano to work, does the repository have to be accessible to the outside?

I developed a rails app in a local directory where my git repository is, too.

I regularly do:

git 开发者_Python百科add .
git commit -am "it works after my recent changes"

now I want to deploy:

cap deploy

But that gives me this error message (paths slightly changed):

  * 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

What am I doing wrong?

I have in my 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"


Your server needs to be able to access the repository where the code is hosted. Right now it's failing when it tries to check out the code because it's not authorized to access your local machine.

I would recommend hosting the repository on Github (free if you don't mind the source being public).

You could also set up a git repository on the server as the remote host and push changes from your local repository there. Then configure capistrano to look for that repository when it deploys.

Happy to elaborate on any of this if it doesn't make sense.


Change the my.domain.tld to localhost or url of your remote server


I think you need to change the deployment strategy to copy:

 set :deploy_via, :copy
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜