MongrelをGodで監視する
だいぶ落ちなくなったmongrelだけど、一応mongrelを監視して再起動する奴をcronで動かしてたんだけど、Godというのをためしてみたらよさそう。
参考
God
http://god.rubyforge.org/
http://rails.takeda-soft.jp/blog/show/213
今はGodはmongrel_claster使わなくなってるみたい。
設定ファイルは公式の方を参考に
macで試してたらメールが送信できない
再起動時とかにメールがほしかった
linuxでうまくいかない。
公式を斜め読みだから、あれだけど。。
公式に書いてあるような設定を書いて
God::Contacts::Email.message_settings = { :from => 'god@example.com' } God::Contacts::Email.server_settings = { :address => "localhost", :port => 25, :domain => "example.com" } God.contact(:email) do |c| c.name = 'crimaru' c.email = 'crimaru@example.com' end
watchのブロックの中に
w.transition(:up, :start) do |on| on.condition(:process_exits) do |c| c.notify = 'crimaru' end end
って書くと、起動しなくなった
on.conditionでだめになってる。
とりあえず
w.start_if do |start| start.condition(:process_running) do |c| c.interval = 5.seconds c.running = false c.notify = "dev" c.notify = "crimaru" end end
とか、それぞれに書いておけば起動するし、メールもくる。
なんだろ。とりあえず、保留
さらに他の鯖で
起動しない
# god -c config.god /opt/ruby186/lib/rubygems.rb:578:in `report_activate_error': RubyGem version error: hoe(1.7.0 not >= 1.8.0) (Gem::LoadError) from /opt/ruby186/lib/rubygems.rb:134:in `activate' from /opt/ruby186/lib/rubygems.rb:158:in `activate' from /opt/ruby186/lib/rubygems.rb:157:in `each' from /opt/ruby186/lib/rubygems.rb:157:in `activate' from /opt/ruby186/lib/rubygems.rb:49:in `gem' from /opt/ruby186/lib/gems/1.8/bin/god:18
hoeをあげれと言われてるようなので
# gem update hoe Updating installed gems Updating hoe Successfully installed rubyforge-1.0.2 Successfully installed hoe-1.8.3 Gems updated: rubyforge, hoe
で、動いた