我使用capistrano 4.4,nginx,unicorn。当我部署时,我有这样的错误:
bin / cap production deploy:check工作正常。
当我第一次运行bin / cap生产部署时,我有一个错误:
...
[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 deployuser@128.199.226.61
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{deployuser@128.199.226.61}
role :web, %w{deployuser@128.199.226.61}
role :db, %w{deployuser@128.199.226.61}
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 :(得分:2)
您可以尝试替换
role :app, %w{deployuser@128.199.226.61}
role :web, %w{deployuser@128.199.226.61}
role :db, %w{deployuser@128.199.226.61}
与
server '128.199.226.61', roles: %w(app web db), primary: true, user: 'deployuser'
在你的production.rb
中据我所知,当您编写三个与一个IP相关的单独条款时,capistrano遇到竞争条件,试图在不同角色下执行相同的任务。