4

サーバーと開発マシンの間で自動デプロイを行うために Capistrano をいじっています。カピストラーノが bundle exec コマンドを使用してサーバーを起動できないように見えることを除いて、ほぼ設定済みです。私は常に次のエラーを受け取ります:

編集: 構成ファイルは現在 /var/www/apps/current/thin.yml にあります

...
  * 「sudo -p 'sudo password: ' bundle exec thin start -C /var/www/thin.config.yml」を実行
    サーバー: ["85.255.206.157"]
    [85.255.206.157] コマンドの実行
 ** [out :: 85.255.206.157] Gemfile が見つかりませんでした
    コマンドは 216ms で終了しました
失敗しました: "sh -c 'sudo -p '\\''sudo パスワード: '\\'' bundle exec thin start -C /var/www/thin.config.yml'" on 85.255.206.157

関連する最後のセクションのみをコピーしました。ファイルなどの全体のコピーは正常に機能します。失敗しているように見えるクラスターを開始しているだけです。すべての Capistrano を処理する deploy.rb ファイルは次のとおりです。

編集: ファイルは次のように変更されました。

require "bundler/capistrano"

# define the application and Version Control settings
set :application, "ESCO Matching Demo"
set :repository,  "svn://192.168.33.70/RubyOnRails/ESCO"
set :deploy_via, :copy

# Set the login credentials for Capistrano
set :user, "kurt"

# Tell Capistrano where to deploy
set :deploy_to, "/var/www/apps"

# Tell Capistrano the servers it can play with
server "85.255.206.157", :app, :web, :db, :primary => true

# Generate an additional task to fire up the thin clusters
namespace :deploy do
  desc "Start the Thin processes"
  task :start do
    sudo "bundle exec thin start -C thin.yml"
  end

  desc "Stop the Thin processes"
  task :stop do
    sudo "bundle exec thin stop -C thin.yml"
  end

  desc "Restart the Thin processes"
  task :restart do
    sudo "bundle exec thin restart -C thin.yml"
  end

  desc "Create a symlink from the public/cvs folder to the shared/system/cvs folder"
  task :update_cv_assets, :except => {:no_release => true} do
    run "ln -s #{shared_path}/cvs #{latest_release}/public/cvs"
  end
end

# Define all the tasks that need to be running manually after Capistrano is finished.
after "deploy:finalize_update", "deploy:update_cv_assets"
after "deploy", "deploy:migrate"

編集:これは私の thin.yml ファイルです

---
pid: tmp/pids/thin.pid
address: 0.0.0.0
timeout: 30
wait: 30
port: 4000
log: log/thin.log
max_conns: 1024
require: []

environment: production
max_persistent_conns: 512
server: 4
daemonize: true
chdir: /var/www/apps/current

編集: 現在、次の問題が発生しています。

  1. 最終ステップでシステムから cap deploy コマンドを実行すると、「GemFile が見つかりません」というエラーが表示されます: サーバーの起動

  2. 移行は実行されません

  3. クラスターを手動で起動することもできなくなったようです。シンの 1 つのインスタンスのみが起動しています。

更新: これは、デプロイ先のサーバーの gem 環境設定です。この情報は、cap シェルを使用して次のコマンドを実行することによって取得されます。

================================================== ==================
インタラクティブな Capistrano シェルへようこそ! これは実験的なものです
機能であり、将来のリリースで変更される可能性があります。「ヘルプ」と入力してください
シェルの使い方のまとめ。
-------------------------------------------------- ------------------
cap> echo $PATH
[85.255.206.157 への接続を確立しています]
パスワード:
 ** [out :: 85.255.206.157] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
cap> gem env
 ** [out :: 85.255.206.157] RubyGems 環境:
 ** [out :: 85.255.206.157] - RUBYGEMS バージョン: 1.3.6
 ** [out :: 85.255.206.157] - ルビー バージョン: 1.8.7 (2010-01-10 パッチレベル 249) [x86_64-linux]
 ** [out :: 85.255.206.157] - インストールディレクトリ: /usr/lib/ruby/gems/1.8
 ** [out :: 85.255.206.157] - ルビー実行可能: /usr/bin/ruby1.8
 ** [out :: 85.255.206.157] - 実行可能ディレクトリ: /usr/bin
 ** [out :: 85.255.206.157] - RUBYGEMS プラットフォーム:
 ** [out :: 85.255.206.157] - ルビー
 ** [出力 :: 85.255.206.157] - x86_64-linux
 ** [out :: 85.255.206.157] - GEM パス:
 ** [アウト :: 85.255.206.157] - /usr/lib/ruby/gems/1.8
 ** [アウト :: 85.255.206.157] - /home/kurt/.gem/ruby/1.8
 ** [out :: 85.255.206.157] - GEM 設定:
 ** [アウト :: 85.255.206.157] - :update_sources => true
 ** [out :: 85.255.206.157] - :verbose => true
 ** [out :: 85.255.206.157] - :benchmark => false
 ** [out :: 85.255.206.157] - :backtrace => false
 ** [アウト :: 85.255.206.157] - :bulk_threshold => 1000
 ** [out :: 85.255.206.157] - リモート ソース:
 ** [アウト :: 85.255.206.157] - http://rubygems.org/
4

2 に答える 2

10

最後に問題を解決しました...最初に、バンドルアプリケーションを環境サーバーとうまく連携させるために、次のスクリプトは本来の処理を実行します。

require "bundler/capistrano"
default_run_options[:pty] = true

# define the application and Version Control settings
set :application, "ESCO Matching Demo"
set :repository,  "svn://192.168.33.70/RubyOnRails/ESCO"
set :deploy_via, :copy
set :user, "kurt"
set :deploy_to, "/var/www/apps"

# Tell Capistrano the servers it can play with

server "85.255.206.157", :app, :web, :db, :primary => true

# Generate an additional task to fire up the thin clusters
namespace :deploy do
  desc "Start the Thin processes"
  task :start do
    run  <<-CMD
      cd /var/www/apps/current; bundle exec thin start -C config/thin.yml
    CMD
  end

  desc "Stop the Thin processes"
  task :stop do
    run <<-CMD
      cd /var/www/apps/current; bundle exec thin stop -C config/thin.yml
    CMD
  end

  desc "Restart the Thin processes"
  task :restart do
    run <<-CMD
      cd /var/www/apps/current; bundle exec thin restart -C config/thin.yml
    CMD
  end

  desc "Create a symlink from the public/cvs folder to the shared/system/cvs folder"
  task :update_cv_assets, :except => {:no_release => true} do
    run <<-CMD
      ln -s /var/www/shared/cvs /var/www/apps/current/public
    CMD
  end
end

# Define all the tasks that need to be running manually after Capistrano is finished.
after "deploy:finalize_update", "deploy:update_cv_assets"
after "deploy", "deploy:migrate"

このスクリプトは、必要な展開構造に適切に移動し、シン プロセスの制御に必要なコマンドを実行できます。問題は、これらを sudo として実行すると cd コマンドが実行されないことでした。これの背後にある理由は、cv がシェルにのみ存在し、sudo に対する既知のコマンドではないためです。

2 つ目の問題は、薄い構成でした。thin.yml に小さいタイプがあったため、シン サーバーを起動できませんでした。以下のスクリプトは、ポート 4000 -> 4003 で実行されている 4 台のシン サーバーのクラスターを起動します。

---
pid: tmp/pids/thin.pid
address: 0.0.0.0
timeout: 30
wait: 30
port: 4000
log: log/thin.log
max_conns: 1024
require: []

environment: production
max_persistent_conns: 512
servers: 4
daemonize: true
chdir: /var/www/apps/current
于 2011-05-24T08:56:34.057 に答える
-2

男、GEM_HOMEまたはGEM_PATHが指している場所を見つけてください。それに違いない。

于 2011-05-18T13:13:34.517 に答える