2010-11-26 4 views
0

私はcronジョブを使用して作業者をスケジュールして、データベース接続を定期的にチェックして(例えば5分)、memcacheキーを更新します。だから私のアプリでは、私はmemcache変数が設定されて見つける。私は、データベースが稼動しているときに、私のページを別の方法でレンダリングします。データベースが私のレールのアプリケーションでダウンしているときにワークリングが機能しない

しかし、問題は、データベースが停止したときに作業者が開始することです。データベースが稼動しているときそれは正しくデータベース接続が存在し、memcache変数を更新することを正しく認識し、すべて正常に動作します。

私は知らないのですが、なぜデータベースがダウンしたときにワーカーが起動しないのですか。 期限が切れています。どのような助けを非常に感謝!

更新:

これはworklingが起動does notの時に私が手にエラーがある

/apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/ gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/mysql_adapter.rb:527:real_connect': Can't connect to MySQL server on '10.223.2.50' (111) (Mysql::Error) from /apps/Symantec/shasta/website/vendor/plugins/workling/script/../lib/workling/starling/poller.rb:35:inから ' 'を/apps/Symantec/shasta/website/vendor/plugins/workling/script/../に参加させてくださいlib/workling/starling/poller.rb:35:listen' from /apps/Symantec/shasta/website/vendor/plugins/workling/script/../lib/workling/starling/poller.rb:35:inそれぞれ ' /apps/Symantec/shasta/website/vendor/plugins/workling/script/../lib/workling/starling/poller.rb:35から: listen' from /apps/Symantec/shasta/website/vendor/plugins/workling/script/listen.rb:19 from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:203:inのロード '/apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:203:inのstart_load' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:296:in start ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb: 51:in watch' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb:51:inフォーク ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitorから.rb:51:watch' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb:45:inの各 ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/ daemons/monitor.rb:45:watch' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb:44:inループ ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0 /lib/daemons/monitor.rb:44:in watch' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb:84:in start_with_pidfi le ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb:64 :fork' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitor.rb:64:in start_with_pidfile ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/monitorから。 rb:111:in start' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/application_group.rb:149:in create_monitor ' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons /application.rb:283:in start' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in run ' /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/からlib/daemons.rb:143:run' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:inで ' を/apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0から呼び出します。 /lib/daemons/cmdline.rb:112:in catch_exceptions' from /apps/Symantec/shasta/website/install/local/ruby-1.8.7-p299/lib/ruby/gems/1.8/gems/daemons-1.1.0/lib/daemons.rb:142:in run ' from script/workling_starling_client:17

答えて

1

作業者は、起動時(常に)にデータベースに接続しようとし、例外をスローしますか?作業員が記録したエラーはありますか?

あなたはあなたのワーカーをRailsに書きましたか?ワーカーが起動できないときにデータベースがダウンしていると想定するシェルスクリプトを記述しますか?

更新:スタックトレースには、開始点:script/workling_starling_client:17があります。 17行目には何がありますか?

最初の行(例外メッセージ自体)に「 real_connect」と表示されます:'10 .223.2.50 '(111)(MySQLのエラー::)でMySQLサーバーに接続できません "あなたが探している答えがあるかどうか、エラーメッセージを確認してください:

(もちろん、ここで止まらないでください。あなたのチェック、例外の欠如がは、接続が確立されていることを意味するものではありませんよう)

begin 
    line_17_is_here 
rescue => e 
    if e.message =~ /Can't connect to MySQL/ 
    handle_your_no_connection_state 
    else 
    raise e 
    end 
end 

質問は次のとおりです:ActiveRecordなしで接続なしの状態を処理できますか?

+0

私はワーカーがスローした例外を添付しました。 – anusuya

+0

私は答えを更新しました。 – Arsen7

+0

私はこれのために全部の作業を落とすことを考えています。代わりにscripts/check.rb内にバックグラウンドルビーscirptを実行します。これはdbが接続されているかどうかを私のウェブサイトがチェックするmemcache変数を更新します。私のルビースクリプトでは、私は 'memcache'を使用する必要があります。それはloadError .cantをスローしてmemcacheを見つける。 – anusuya

関連する問題