Skip to content

Instantly share code, notes, and snippets.

@Shinpeim
Forked from kkosuge/god.md
Created January 17, 2012 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shinpeim/1627568 to your computer and use it in GitHub Desktop.
Save Shinpeim/1627568 to your computer and use it in GitHub Desktop.
Godのかんたんなつかいかた

godのインストール

sudo gem install god

godの起動

$ god -c god.rb

godを止める

$ god stop heimin

かんたんで便利ですね

# coding: utf-8
require 'god' #かっこいい
God.watch do |w|
w.name = "heimin" #開始されるやつの呼び名(てきとう)
w.interval = 60.second #監視時間間隔
w.start = "ruby #{File.dirname( __FILE__ ) + '/heimin.rb'}" #動かすプログラム
w.log = "#{File.dirname( __FILE__ ) + '/heimin.log'}" #ログを残す場合の書き込み場所
# プロセスが落ちいていた場合は起動
w.start_if do |start|
start.condition(:process_running) do |c|
c.running = false
end
end
# メモリが10MB超えたら再起動
w.restart_if do |restart|
restart.condition(:memory_usage) do |c|
c.above = 10.megabytes
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment