2015-05-11 176 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的運行當你編寫關於一個知識產權的三個單獨的條款時,試圖在不同的角色下執行相同的任務。