问题
I'm using the gem Capistrano ~2.15.5 and deploying my application to my remote server. Everything works fine until the end of the cap prod deploy command. I'm receiving this error:
** [52.74.34.196 :: out] /bin/bash: ebs/apps/CloudTrendz/releases/20150318203140/REVISION: No such file or directory
** [52.74.34.196 :: out]
command finished in 4923ms
*** [deploy:update_code] rolling back
* executing "rm -rf ebs/apps/CloudTrendz/releases/20150318203140; true"
servers: ["52.74.34.196"]
[52.74.34.196] executing command
command finished in 411ms
failed: "/bin/bash --login -c 'git clone -b master git@github.com:prashant4224/CloudTrendz.git ebs/apps/CloudTrendz/releases/20150318203140 && cd ebs/apps/CloudTrendz/releases/20150318203140 && git checkout -b deploy 16cc51ebe1acd97cb489f10313d85f7ae9a69f6b && rm -Rf ebs/apps/CloudTrendz/releases/20150318203140/.git && (echo 16cc51ebe1acd97cb489f10313d85f7ae9a69f6b > ebs/apps/CloudTrendz/releases/20150318203140/REVISION)'" on 52.74.34.196
Here deploy.rb
require "bundler/capistrano"
set :application, "CloudTrendz"
set :repository, "git@github.com:prashant4224/CloudTrendz.git"
set :deploy_to, "ebs/apps/#{application}"
set :applicationdir, "ebs/apps/#{application}"
set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
set :branch, "master"
set :deploy_to, applicationdir
set :deploy_via, :export
set :scm_verbose, true
set :user, "ubuntu"
set :use_sudo, false
set :rails_env, "production"
set :keep_releases, 2
set :precompile_only_if_changed, true
default_run_options[:pty] = true
default_run_options[:shell] = '/bin/bash --login'
ssh_options[:keys] = %w(~/.ssh/prashantec2.pem)
after "deploy:update_code", "deploy:copy_configs"
task :prod do
set :domain, "52.74.34.196"
set :repository, "git@github.com:prashant4224/CloudTrendz.git"
set :local_repository, "git@github.com:prashant4224/CloudTrendz.git"
set :branch, "master"
set :scm_verbose, true
server "52.74.34.196", :app, :web, :db, :primary => true
set :deploy_env, "prod"
"deploy"
end
namespace :deploy do
task :copy_configs, :roles => :app do
run "cp #{release_path}/../../shared/database.yml #{release_path}/config/database.yml"
end
task :migrate, :roles => :app do
run "cd #{release_path} && bundle exec rake db:migrate"
end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path, 'tmp', 'restart.txt')}"
if deploy_env == 'prod'
tag_name = Time.now.strftime("deploy_%Y_%m_%d_%H_%M")
system "git tag -a -m 'Deployment on prod' #{tag_name}"
system "git push origin #{tag_name}"
if $? != 0
raise "Pushing tag to origin failed"
end
end
end
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
after "deploy:update", "deploy:migrate", "deploy:cleanup"
What is wrong with this code?
Thank you in advance
回答1:
It looks to me like it is failing when cloning the git repository from Github. Make sure that you've added the remote server's SSH key to the Github repository.
You can verify if this is the problem by SSH'ing into the remote server and attempting to run:
git clone git@github.com:prashant4224/CloudTrendz.git
If this fails, copy the contents of ~/.ssh/id_rsa.pub
and then go to https://github.com/prashant4224/CloudTrendz/settings/keys
, click "Add deploy key" and paste it in.
If ~/.ssh/id_rsa.pub
does not exist on the remote server, run ssh-keygen
to create it.
来源:https://stackoverflow.com/questions/29132472/deploy-with-capistrano-error-revision-no-such-file-or-directory