2015-05-11 149 views
1

我使用capistrano 4.4,nginx,独角兽。当我部署时,我有这样的错误:capistrano 3部署错误

斌/帽生产部署:检查工作正常。

当我运行斌/帽生产部署的第一次,我有一个错误:

... 
[7e794b92]  Cloning into bare repository 
'opt/www/foreignernetwork/repo'... 
INFO [7e794b92] Finished in 3.847 seconds with exit status 0 (successful). 
DEBUG [19e30ae6] Running /usr/bin/env if test ! -d opt/www/foreignernetwork/repo; then echo "Directory does not exist 'opt/www/foreignernetwork/repo'" 1>&2; false; fi as [email protected] 
DEBUG [19e30ae6] Command: if test ! -d opt/www/foreignernetwork/repo; then echo "Directory does not exist 'opt/www/foreignernetwork/repo'" 1>&2; false; fi 
DEBUG [19e30ae6] Directory does not exist 'opt/www/foreignernetwork/repo' 
(Backtrace restricted to imported tasks) 
cap aborted! 
.... 

当我再次运行它,它说:

[4daafe62] Command: cd opt/www/foreignernetwork && (GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/foreignernetwork/git-ssh.sh /usr/bin/env git clone --mirror https://github.com/KonstantinSmirnov/foreignernetwork.git opt/www/foreignernetwork/repo) 
DEBUG [4daafe62] fatal: destination path 'opt/www/foreignernetwork/repo' already exists and is not an empty directory. 
(Backtrace restricted to imported tasks) 
cap aborted! 
.... 
SSHKit::Command::Failed: git exit status: 128 
git stdout: Nothing written 
git stderr: fatal: destination path 'opt/www/foreignernetwork/repo' already exists and is not an empty directory. 
.... 

如果我删除此文件夹,它再次重复相同。

这里是我的文件:

deploy.rb:

lock '3.4.0' 

set :application, 'foreignernetwork' 
set :repo_url, 'https://github.com/KonstantinSmirnov/foreignernetwork.git' 
set :scm, 'git' 
set :deploy_via, :copy 

set :deploy_to, 'opt/www/foreignernetwork' 
set :user, 'deployuser' 
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets} 
set :ssh_options, { :forward_agent => true, :port => 12531 } 
set :use_sudo, true 

namespace :deploy do 

%w[start stop restart].each do |command| 
desc 'Manage Unicorn' 
task command do 
    on roles(:app), in: :sequence, wait: 1 do 
    execute "/etc/init.d/unicorn_#{fetch(:application)} #{command}" 
    end 
end 
end 

    after :publishing, :restart 

    after :restart, :clear_cache do 
on roles(:web), in: :groups, limit: 3, wait: 10 do 
    # Here we can anything such as: 
    # within release_path do 
    # execute :rake, 'cache:clear' 
    # end 
    end 
    end 

end 

production.rb:

role :app, %w{[email protected]} 
role :web, %w{[email protected]} 
role :db, %w{[email protected]} 

unicorn.rb:

root = "/opt/www/foreignernetwork/current" 
working_directory root 
pid "#{root}/tmp/pids/unicorn.pid" 
stderr_path "#{root}/log/unicorn.log" 
stdout_path "#{root}/log/unicorn.log" 

listen "/tmp/unicorn.foreignernetwork.sock" 
worker_processes 1 
timeout 30 

请你能帮忙我想出如何解决它?已经挖了一切......

+0

你能检查是否[this](http://stackoverflow.com/questions/24314972/capistrano-destination-path-already-exists-not-an-empty-directory)发布回答你的问题? –

+0

不,我已经检查过,我没有翻倍.. –

+0

将尝试从一开始就做所有的事情 –

回答

2

你可以尝试在你的production.rb与

server '128.199.226.61', roles: %w(app web db), primary: true, user: 'deployuser' 

更换

role :app, %w{[email protected]} 
role :web, %w{[email protected]} 
role :db, %w{[email protected]} 

至于我读过,Capistrano的运行当你编写关于一个知识产权的三个单独的条款时,试图在不同的角色下执行相同的任务。