1

少なくとも、それは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]

デプロイディレクトリに「current」、「shared」、「release」フォルダを手動で作成し、適切なuser:groupを割り当てます。もともとはdirsの権限の問題を取得していましたが、それを解決しました。ここではちょっと途方に暮れていますが、解決策を探すことの多くは、今のところ何も得られていません。ここでの提案や経験は大歓迎です!

テストでは、私は同時にベイルcap staging deployも生産に挑戦するだろうと思っていました...一貫性について何か賢いことです。cap production deploy

4

2 に答える 2

6

更新:それを見つけた

'current'ディレクトリを削除し、capistranoに最新リリースへの'current'シンボリックリンクを作成させることで修正しました。

少し片付けてみます。私は実際に「current」などのフォルダを作成していました。「mkdircurrent」のように。これは、capistranoがシンボリックリンクを作成するのを邪魔するだけです。試してみて、「bob」というフォルダを作成し、同じディレクトリに「bob」というシンボリックリンクを作成して、ディレクトリ「bob」内にシンボリックリンク「bob」を配置する場所にポイントします。

'current''shared'などのディレクトリを削除すると、capistranoは'current'およびその他の必要なシンボリックリンクを作成できます。したがって、具体的には「current」ディレクトリを削除することで、capistranoは「releases」ディレクトリの下にある最新のデプロイを指す「current」シンボリックリンクを作成できました。

以下のエラーに注意してください。これも問題になっています。

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

それが失敗した理由。「current」という名前のフォルダを作成しました。これが問題です。これはディレクトリではなく、capistranoが作成するシンボリックリンクであると想定されています。

それらのフォルダを作成することにより、デプロイが中断されました。これらのフォルダを削除すると、capistranoは同じ名前のシンボリックリンクを作成できました。それ以来、スムーズな航海。

于 2012-05-30T20:56:05.963 に答える
0

同様の問題を突き止めました。

これが私が持っていたエラーの最初のエラーです:

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構成を含むjailを編集する

$ sudo nano /etc/fail2ban/jail.local

[SSH]を探し、有効に設定= false [ssh-ddos]を見つけ、有効に設定= false

変更とopen-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のダウングレード、gemの削除などを行った後、ドキュメントルートに移動し、ディレクトリの内容を一覧表示しました。ディレクトリがデプロイユーザーのグループにないls -laことに気づき、現在のフォルダ( )とすべてを削除しました。うまくいきました。幸運を。currentsudo rm -rf current

于 2014-05-18T04:27:18.827 に答える