Capistrano & Git развернуть. Ошибка «роковое происхождение» не является git-хранилищем » - PullRequest
1 голос
/ 25 февраля 2012

Я клонировал код с Git с моей локальной машины на GitHub. Теперь я хочу развернуть свой код на рабочем сервере с Capistrano.

Я могу подключиться по SSH с моей локальной машины и с рабочего сервера на Github. Я могу сделать git clone из GitHub на моем производственном сервере. Но с cap deploy у меня есть эта ошибка:

роковое 'origin' не похоже на git-репозиторий

me@ubuntu:~/projects/4b1_1602$ cap deploy

  * 20:36:56 == Currently executing `deploy'
  * 20:36:56 == Currently executing `deploy:update'
 ** transaction: start
  * 20:36:56 == Currently executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:MyName/MyRepo.git master"
    command finished in 3390ms
  * executing "if [ -d /home/mysite/shared/cached-copy ]; then cd /home/mysite/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 85617dd2acf44e383f238e5b7bfcbd50ad4e54cc && git clean -q -d -x -f; else git clone -q git@github.com:MyName/MyRepo.git /home/mysite/shared/cached-copy && cd /home/mysite/shared/cached-copy && git checkout -q -b deploy 85617dd2acf44e383f238e5b7bfcbd50ad4e54cc; fi"

servers: ["mysite.com"]

Password: 

    [mysite.com] executing command

 ** [mysite.com :: err] fatal: 'origin' does not appear to be a git repository

 ** [mysite.com :: err] fatal: The remote end hung up unexpectedly
    command finished in 695ms

*** [deploy:update_code] rolling back

  * executing "rm -rf /home/mysite/releases/20120225163720; true"

    servers: ["mysite.com"]

    [mysite.com] executing command

    command finished in 409ms

failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'if [ -d /home/mysite/shared/cached-copy ]; then cd /home/mysite/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 85617dd2acf44e383f238e5b7bfcbd50ad4e54cc && git clean -q -d -x -f; else git clone -q git@github.com:MyName/MyRepo.git /home/mysite/shared/cached-copy && cd /home/mysite/shared/cached-copy && git checkout -q -b deploy 85617dd2acf44e383f238e5b7bfcbd50ad4e54cc; fi'" on mysite.com
me@ubuntu:~/projects/4b1_1602$ 

Мой deploy.rb:

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))

require 'rvm/capistrano'
require 'bundler/capistrano'
require 'capistrano_colors'
server "mysite.com", :app, :web, :db, :primary => true

set :application, "mysite"
set :rails_env, "production"
set :app_dir, "/home/#{application}"

set :deploy_to, "#{app_dir}"
set :user, "#{application}"
set :use_sudo, false

set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"

set :rvm_ruby_string, '1.9.3'
set :rvm_type, :user

set :repository, "git@github.com:MyName/MyRepo.git"


set :scm, 'git'
set :branch, 'master'
set :scm_verbose, false
set :deploy_via, :remote_cache
# set :repository_cache, "cached_copy" 
#ssh_options[:forward_agent] = true


namespace :deploy do

desc "Server restart."
task :restart do
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -USR2      `cat #{unicorn_pid}`; else cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D; fi"
end
task :start do
run "bundle exec unicorn -c #{unicorn_conf} -E #{rails_env} -D"
end
task :stop do
run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -QUIT  `    cat #{unicorn_pid}`; fi"
  end

  desc "Symlink to public."
  task :symlink_public do
    run "mv #{release_path}/public #{release_path}/public_static"
    run "ln -s #{shared_path}/public #{release_path}/public"
    run "cp -r #{release_path}/public_static/* #{release_path}/public"
    run "rm -r #{release_path}/public_static"
  end
  desc "Compile asets"
  task :assets do
    run "cd #{release_path}; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
  end
  desc "Symlink to upload."
  task :symlink_upload do
    #run "unlink #{release_path}/public/uploads"
    run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
    run "chmod 755 #{app_dir}"
  end

  desc "Database migrate."
  task :db_migrate do
    run "cd #{release_path}; bundle exec rake db:migrate RAILS_ENV=#{rails_env}"
  end

  desc "Update the crontab file"
  task :update_crontab, :roles => :db do
    run "cd #{release_path} && bundle exec whenever --update-crontab #{application}"
  end

end


#before "deploy:symlink", "deploy:symlink_public"
#before "deploy:symlink", "deploy:assets"
before 'deploy:symlink', 'deploy:symlink_upload'
after 'deploy:update_code', 'deploy:db_migrate'
#after "deploy:symlink", "deploy:update_crontab"
#before 'deploy:finalize_update', 'deploy:public_folders'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...