使用capistrano部署错误:... / REVISION没有这样的文件或目录

时间:2015-03-18 20:55:46

标签: ruby-on-rails capistrano web-deployment

我正在使用gem Capistrano~2.15.5并将我的应用程序部署到我的远程服务器。一切正常,直到 cap prod deploy 命令结束。我收到了这个错误:

** [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

这里是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"

此代码有什么问题?

提前谢谢

1 个答案:

答案 0 :(得分:0)

在我看来,当从Github克隆git存储库时,它失败了。确保您已将远程服务器的SSH密钥添加到Github存储库。

您可以通过SSH验证这是否是问题并进入远程服务器并尝试运行:

git clone git@github.com:prashant4224/CloudTrendz.git

如果失败,请复制~/.ssh/id_rsa.pub的内容,然后转到https://github.com/prashant4224/CloudTrendz/settings/keys,点击"添加部署密钥"并粘贴它。

如果远程服务器上不存在~/.ssh/id_rsa.pub,请运行ssh-keygen来创建它。