Calling god stop <watch> soon after starting it

12 views
Skip to first unread message

melfar

unread,
May 23, 2009, 11:17:40 AM5/23/09
to god.rb
Hello,

I'm dealing with non-daemon watches and I've noticed that stopping a
freshly-started process is delayed by half a minute or so (a watch
that has been running for a minute or more is stopped immediately, but
it didn't occure to me while I was testing it initially).

Steps to reproduce: set a non-daemon watch on this script:

#!/usr/bin/env ruby

$running = true
STDOUT.sync = true
puts "Hello ruby"
Signal.trap("TERM") do
$running = false
end
while($running) do
sleep 1
end
puts "Exiting"

like so:

God.pid_file_directory = "#{RAILS_ROOT}/log"
God.watch do |w|
w.name = "test"
w.interval = 60.seconds
w.start = "#{RAILS_ROOT}/test.rb"
w.log = "#{RAILS_ROOT}/log/test.log"
end

then load it into god, execute
god start test
god stop test

there will be a half a minute delay before "Exiting" message appears
in test.log

This behavior is not an issue to me, since it seems that it works fine
after the start up, but it got me confused while I was testing start/
stop/restart initially.

On a side note, don't you think it might be a good default to have
STDOUT.sync = true set for the spawned script, or maybe give a watch
option for that behavior?

Thanks!
Reply all
Reply to author
Forward
0 new messages