Rails Capistrano部署 - 修订:没有这样的文件或目录

时间:2013-09-16 20:23:13

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

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

 ** [ps123456.dreamhostps.com :: out] sh: myapp.git/releases/20130916201449/REVISION: No such file or directory
    command finished in 2266ms
*** [deploy:update_code] rolling back
  * executing "rm -rf myapp.git/releases/20130916201449; true"
    servers: ["ps123456.dreamhostps.com"]
    [ps123456.dreamhostps.com] executing command
    command finished in 254ms
failed: "sh -c 'git clone --depth 1 ssh://username@ps123456.dreamhostps.com/~/myapp.git myapp.git/releases/20130916201449 && cd myapp.git/releases/20130916201449 && git checkout -b deploy 497af4d996358f8d1f42dc9658e276ee8d9fa64f && git submodule init && git submodule sync && export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && git submodule update --init $GIT_RECURSIVE && rm -Rf myapp.git/releases/20130916201449/.git && (echo 497af4d996358f8d1f42dc9658e276ee8d9fa64f > myapp.git/releases/20130916201449/REVISION)'" on ps123456.dreamhostps.com

这是我的deploy.rb

require 'bundler/capistrano'
set :user, 'username'
set :domain, 'ps123456.dreamhostps.com'
set :applicationdir, "myapp.git"

default_run_options[:pty] = true
set :scm, 'git'
set :repository,  "ssh://username@ps123456.dreamhostps.com/~/myapp.git"
set :git_enable_submodules, 1 # if you have vendored rails
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true

# roles (servers)
role :web, domain
role :app, domain
role :db,  domain, :primary => true

# deploy config
set :deploy_to, applicationdir
set :deploy_via, :export

# additional settings
default_run_options[:pty] = true  # Forgo errors when deploying from windows

# Passenger
namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

出了什么问题?

2 个答案:

答案 0 :(得分:1)

很难确切地说,但是当你尝试将git修订版推入文件REVISION时,很明显你的releases/#{revision}目录丢失了。

一个可能应该修复的问题是你的:deploy_to目录与你克隆的git repo在同一台机器上的目录相同。试试这个:

在您的deploy.rb

set :deploy_to, "/home/#{user}/app/#{application}"

然后确保第一次运行:

cap deploy:setup

然后随意:

cap deploy

答案 1 :(得分:1)

经过多次头部刮伤,奇怪的是,cap deploy:setup是我的垮台。我仍然不确定发生了什么,但我已经彻底测试并验证删除部署目录并重新部署应用程序而不运行cap deploy:setup将会有效。

出于某种原因,即使在成功部署之后运行cap deploy:setup也会导致权限错误,并导致cap deploy无法创建和写入目录。