【问题标题】:Deploy with capistrano error: …/REVISION No such file or directory部署时出现 capistrano 错误:…/REVISION 没有这样的文件或目录
【发布时间】:2015-03-18 20:55:46
【问题描述】:

我正在使用 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"

这段代码有什么问题?

提前谢谢你

【问题讨论】:

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


    【解决方案1】:

    在我看来,从 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 来创建它。

    【讨论】:

    • 您是否可以从远程服务器手动克隆存储库?
    • 是的,我可以在远程服务器@infused 上手动克隆存储库
    • 查看stackoverflow.com/questions/18836635/… 上接受的答案。会不会是这个问题?
    • 我通过修改路径set :applicationdir, "/home/ubuntu/ebs/apps/#{application}" @infused解决了上述错误,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多