これはおそらくかなり初心者向けの修正であるため、事前にお詫び申し上げます。
神と一緒にコントロールしたい単純なプロセスがあります。この段階でのプロセスは、基本的にはloop do; sleep 1; end
. 構成ファイルは最小限です。
God.watch do |w|
w.name = "punter"
w.start = "bundle exec rails runner ./script/fetcher_daemon.rb"
w.keepalive
end
プロセスは何度も何度も開始され続け、pid ファイルはリセットされ続けます。神がすべてを正常に開始できるように、プロセスが実行されていることを認識せずに再起動します。以下のログ ファイルを参照してください。
bundle exec rails runner ./script/fetcher_daemon.rb
コマンドラインから実行でき、問題なく動作します。
私のセットアップは Mint Linux で、rvm を使用しています。
I [2012-08-23 19:33:42] INFO: Loading ./script/punter.god
I [2012-08-23 19:33:42] INFO: Syslog enabled.
I [2012-08-23 19:33:42] INFO: Using pid file directory: /home/matt/.god/pids
I [2012-08-23 19:33:42] INFO: Started on drbunix:///tmp/god.17165.sock
I [2012-08-23 19:33:42] INFO: punter move 'unmonitored' to 'up'
D [2012-08-23 19:33:42] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x917d7d0> in 0 seconds
I [2012-08-23 19:33:42] INFO: punter moved 'unmonitored' to 'up'
I [2012-08-23 19:33:42] INFO: punter [trigger] process is not running (ProcessRunning)
D [2012-08-23 19:33:42] DEBUG: punter ProcessRunning [true] {true=>:start}
I [2012-08-23 19:33:42] INFO: punter move 'up' to 'start'
I [2012-08-23 19:33:42] INFO: punter start: bundle exec rails runner ./script/fetcher_daemon.rb
D [2012-08-23 19:33:42] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x917d7d0> in 0 seconds
I [2012-08-23 19:33:42] INFO: punter moved 'up' to 'up'
I [2012-08-23 19:33:42] INFO: punter [ok] process is running (ProcessRunning)
D [2012-08-23 19:33:42] DEBUG: punter ProcessRunning [false] {true=>:start}
D [2012-08-23 19:33:42] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x917d7d0> in 5 seconds
I [2012-08-23 19:33:47] INFO: punter [trigger] process is not running (ProcessRunning)
D [2012-08-23 19:33:47] DEBUG: punter ProcessRunning [true] {true=>:start}
I [2012-08-23 19:33:47] INFO: punter move 'up' to 'start'
I [2012-08-23 19:33:47] INFO: punter start: bundle exec rails runner ./script/fetcher_daemon.rb
D [2012-08-23 19:33:48] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x917d7d0> in 0 seconds
I [2012-08-23 19:33:48] INFO: punter moved 'up' to 'up'
I [2012-08-23 19:33:48] INFO: punter [ok] process is running (ProcessRunning)
D [2012-08-23 19:33:48] DEBUG: punter ProcessRunning [false] {true=>:start}
D [2012-08-23 19:33:48] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x917d7d0> in 5 seconds