0

ユニコーンとdelayed_jobプロセスを再起動できないようにするのに少し苦労しています。これはUbuntuのupstartで簡単に開始できるため、全体的なマネージャーとしてbluepillを使用することにしました。bluepill用のRVMラッパーを作成しましたが、upstartスクリプトは適切に機能します(開始と停止は簡単です。

# bluepill - process monitor
#
# simple process monitoring tool

description "simple process monitoring tool"

start on started nginx
stop on stopping nginx

expect daemon
#respawn

exec bootup_bluepill load /home/deployer/apps/nzswarranty/current/config/production.pill

次は、bluepill構成ファイルです。

Bluepill.application("nzswarranty", :log_file => "/var/log/bluepill.log") do |app|
  app.working_dir = '/home/deployer/apps/nzswarranty/current'
  app.uid = "deployer"
  app.gid = "staff"

  app.process("unicorn") do |process|
    process.start_command = "bundle exec unicorn_rails -c config/unicorn.rb -D"
    process.stop_command  = "kill -s QUIT `cat /tmp/unicorn.nzswarranty.pid`"
    process.restart_command  = "kill -s USR2 `cat /tmp/unicorn.nzswarranty.pid`"
    process.pid_file = '/tmp/unicorn.nzswarranty.pid'
    process.start_grace_time = 15.seconds
    process.stop_grace_time = 15.seconds
  end

  app.process("delayed_job") do |process|
    process.environment = { 'RAILS_ENV' => 'production' }
    process.start_command = 'script/delayed_job start'
    process.stop_command  = 'script/delayed_job stop'
    process.pid_file = '/home/deployer/apps/nzswarranty/shared/pids/delayed_job.pid'
    process.start_grace_time = 15.seconds
    process.stop_grace_time = 15.seconds
  end

end

サーバーにはシステム全体のRVMがインストールされており、Gemを管理するバンドラーがあります。これはRails3.1アプリです。

基本的に、delayed_jobを実行せずにbluepillを起動すると、起動しようとすると次のようになります。

W, [2012-01-05T13:37:55.185626 #28201]  WARN -- : [nzswarranty:delayed_job] Start command execution returned non-zero exit code:
W, [2012-01-05T13:37:55.185780 #28201]  WARN -- : [nzswarranty:delayed_job] {:stdout=>"", :stderr=>"/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- bundler/setup (LoadError)\n\tfrom /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'\n\tfrom /home/deployer/apps/nzswarranty/current/config/boot.rb:6:in `<top (required)>'\n\tfrom <internal:lib/rubygems/custom_require>:29:in `require'\n\tfrom <internal:lib/rubygems/custom_require>:29:in `require'\n\tfrom /home/deployer/apps/nzswarranty/current/config/application.rb:1:in `<top (required)>'\n\tfrom <internal:lib/rubygems/custom_require>:29:in `require'\n\tfrom <internal:lib/rubygems/custom_require>:29:in `require'\n\tfrom /home/deployer/apps/nzswarranty/current/config/environment.rb:2:in `<top (required)>'\n\tfrom <internal:lib/rubygems/custom_require>:29:in `require'\n\tfrom <internal:lib/rubygems/custom_require>:29:in `require'\n\tfrom script/delayed_job:3:in `<main>'\n", :exit_code=>1}
I, [2012-01-05T13:37:55.186003 #28201]  INFO -- : [nzswarranty:delayed_job] Going from down => starting

これにもbundleexecを使用してみましたが、バンドル実行可能ファイルが見つからないと表示されます。私の疑いは、環境が正しくロードされていないことです。任意のヒント?プロジェクトのルートにある.rvmrcファイルからロードされるRVMgemsetがあります。bluepill構成でもこのgemsetに切り替える必要がありますか?

4

1 に答える 1

0

さて、最終的にはかなり簡単でした。何が起こっていたのかというと、rootとしてグローバルrvm gemsetにbluepillをインストールし、環境でグローバルgemsetを使用するラッパーを作成したことです(つまり、bluepillは正常に起動しましたが、適切なgemsetに他のgemが表示されませんでした(保証))。基本的に、グローバルジェムセットからブルーピルを削除し、保証ジェムセットにインストールしました。次に、ラッパーを再度作成しました。

rvmsudo rvm wrapper ruby-1.9.2-p290@warranty bootup bluepill

また、ユニコーンを起動しようとしたときに別の奇妙なエラーが発生しましたが、RAILS_ENVを渡していないことに気付きました。これが私の最後の.pillです。

Bluepill.application("nzswarranty", :log_file => "/var/log/bluepill.log") do |app|
    app.working_dir = '/home/deployer/apps/nzswarranty/current'
    app.uid = 'deployer'
    app.gid = 'staff'
    app.environment = { 'RAILS_ENV' => 'production' }

    app.process("unicorn") do |process|
        process.start_command = "bundle exec unicorn_rails -c config/unicorn.rb -D"
        process.stop_command  = "kill -s QUIT `cat /tmp/unicorn.nzswarranty.pid`"
        process.restart_command  = "kill -s USR2 `cat /tmp/unicorn.nzswarranty.pid`"
        process.pid_file = '/tmp/unicorn.nzswarranty.pid'
        process.start_grace_time = 30.seconds
        process.stop_grace_time = 30.seconds
    end

    app.process("delayed_job") do |process|
        process.start_command = 'bundle exec script/delayed_job start'
        process.stop_command  = 'bundle exec script/delayed_job stop'
        process.pid_file = '/home/deployer/apps/nzswarranty/shared/pids/delayed_job.pid'
        process.start_grace_time = 30.seconds
        process.stop_grace_time = 30.seconds
    end
end

Gemfileからgemの完全なセットをロードするために、他のコマンドの前にbundleexecを使用する必要があることに注意することが重要です。

于 2012-01-13T03:18:09.013 に答える