我怎样才能得到Capistrano的停在部署失败:create_symlink?(How can I

2019-07-29 13:41发布

至少,这是它看起来像Capistrano的失败。 这使得它所有的方式完成部署,并在年底。 这里是输出。

* executing `deploy:create_symlink'
* executing "rm -f ~/xxx.xx.xx/test/current && ln -s ~/xxx.xx.xx/test/releases/20120525193307 ~/xxx.xx.xx/test/current"
servers: ["test.xxx.xx.xx"]
["test.xxx.xx.xx"] executing command
 ** [out :: test.xxx.xx.xx] rm: cannot remove `/var/www/vhosts/xxx.xx.xx/test/current': I command finished in 460ms
*** [deploy:create_symlink] rolling back
*** no previous release to rollback to, rollback of symlink skipped
* executing "rm -rf /var/www/vhosts/xxx.xx.xx/test/releases/20120525195909; true"
servers: ["test.xxx.xx.xx"]
[test.xxx.xx.xx] executing command
command finished in 524ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'default' -c 'rm -f /var/www/vhosts/xxx.xx.xx/test/current && ln -s /var/www/vhosts/xxx.xx.xx/test/releases/20120525195909 /var/www/vhosts/xxx.xx.xx/test/current'" on xxx.xx.xx

该应用程序使用Capistrano的(2.12.0)Capistrano的-EXT(1.2.1)显然有更多的宝石只是想放什么,似乎相关,请让我知道如果有更多的信息将是有益的。

这里是deploy.rb

require "rvm/capistrano"
require 'bundler/capistrano'
require 'capistrano/ext/multistage'

set :stages, %w(staging production)
set :default_stage, 'staging'

set :application, 'xxx'

# trying to not use sudo on the deployment
#set :use_sudo, false

#set :copy_exclude, [".git", "spec"]

set :repository,  '~/git/xxx.git'
set :local_repository, "~/rorwork/xxx/.git"
set :scm, :git
set :user, 'xxx'
set :group, 'xxxx'
ssh_options[:forward_agent] = true
set :branch, 'master'
set :deploy_via, :remote_cache
set :scm_command, "/usr/local/bin/git"
set :local_scm_command, :default
default_run_options[:pty] = true
set :normalize_asset_timestamps, false #for asset piple

set :dbuser, 'xxx'
set :dbpass, 'xxx'

# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
 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

和staging.rb

set :domain, 'test.xxx.xx.xx'

role :web, domain                          # Your HTTP server, Apache/etc
role :app, domain                          # This may be the same as your `Web` server
role :db,  domain, :primary => true        # This is where Rails migrations will run

set :deploy_to, "/var/www/vhosts/xxx.xx.xx/test"
set :rails_env, 'staging'
set :rack_env, rails_env

set :dbname, "xxx_staging"

#set :bundle_without, [:test, :development, :production]

我手动创建“当前”,“共享”和“释放”在deploy目录的文件夹,并分配适当的用户:组。 原本是让上显示目录的权限问题,但得到了解决。 在还挺这里损失,多寻求解决被扣除什么作为呢。 任何建议或经验在这里非常感谢!

在测试cap staging deploy想我会尝试对生产,以及cap production deploy的同时捞出......一些聪明约一致性。

Answer 1:

UPDATE:发现它

删除“当前”目录下,并让Capistrano的创建“当前”符号连接固定它的最新版本。

我会尽力把它清除掉一点。 我其实是在创建文件夹“当前”和这样的,“目前的mkdir”等。 这只是帮倒忙Capistrano的创建符号链接的方式。 试试吧,做一个名为“鲍勃”,那么在相同的目录文件夹创建一个名为“鲍勃”的符号链接,并指出它的地方,它可能会放符号链接“鲍勃”目录内的“鲍勃”。

当我删除“当前”“共享”等,目录,Capistrano的可以创建“当前”和其它必要的符号链接。 因此,具体删除“当前”目录允许Capistrano的创建“当前”符号链接,只是指向最新部署的“释放”目录下。

注意下面的错误,这也是问题。

** [out :: test.xxx.xx.xx] rm: cannot remove `/var/www/vhosts/xxx.xx.xx/test/current': I command finished in 460ms

它失败的原因。 我已经创建了一个名为文件夹“电流”。 这就是问题。 它不应该是一个目录,它应该是Capistrano的创建符号链接。

通过创建这些文件夹它打破了部署。 删除这些文件夹允许Capistrano的创建同名的符号链接。 一帆风顺至今。



Answer 2:

我只是找到了一个类似的问题。

这里的错误第一个错误我有:

cap aborted! Errno::ECONNREFUSED: Connection refused - connect(2) for "{my-ip-address}" port {my-ssh-port}

我也得到这个类似的错误:

Tasks: TOP => git:create_release (See full trace by running task with --trace) The deploy has failed with an error: #<Errno::ECONNREFUSED: Connection refused - connect(2) for "my-ip-address" port {my-port}>

事实证明,我的服务器运行的fail2ban这是并发SSH会话的问题。 为了解决这个,我只是做了以下内容:

编辑包含SSH配置监狱

$ sudo nano /etc/fail2ban/jail.local

寻找[SSH],并设置启用=假的发现[SSH-DDOS],并设置启用=假

记住你的变化和开放SSH后重新启动的fail2ban(如果那是你的使用)

$ sudo service fail2ban reload
$ sudo /etc/init.d/ssh reload

它值得注意的是,连接将在部署不同的步骤(任务)被拒绝。 例如重新启动和快速后bundle exec cap production deploy:check一切似乎罚款。 然后我试图部署并收到了同样的错误,但不同的任务的执行过程中。 我也用我禁用,没有问题重新启用UFW。 UFW没有上述问题的原因。

我解决了这个问题之后Capistrano的将无法创建符号链接从当前目录到最新版本。 下面的错误是:

Tasks: TOP => deploy:symlink:release The deploy has failed with an error: #<SSHKit::Command::Failed: rm exit status: 1 rm stdout: Nothing written rm stderr: Nothing written > ** Invoke deploy:failed (first_time) ** Execute deploy:failed

广泛阅读,改变sshkit版本,降级Capistrano的,消除宝石,等以后,我浏览到我的文档根目录,并列出目录内容ls -la我注意到, current目录不是部署用户组中,我删除当前文件夹( sudo rm -rf current )和一切工作正常。 祝好运。



文章来源: How can I get Capistrano to stop failing at deploy:create_symlink?