0

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

出了什么问题?

4

2 回答 2

1

经过多次挠头,奇怪的是,这cap deploy:setup就是我的失败。我仍然不确定发生了什么,但我已经彻底测试并验证了删除部署目录并重新部署应用程序而不运行是可行的cap deploy:setup

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

于 2013-09-17T20:42:19.500 回答
1

很难准确地说出来,但很明显,releases/#{revision}当您尝试将 git 修订版推送到文件 REVISION 时,您的目录已丢失。

一个可能应该解决的问题是您:deploy_to的目录与您要克隆的 git 存储库在同一台机器上的目录相同。试试这个:

在你的 deploy.rb

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

然后确保第一次运行它:

cap deploy:setup

然后随意:

cap deploy
于 2013-09-16T21:44:31.760 回答