I'm trying to start and stop an infinite loop daemon using the daemons
gem.
Looking at the home page, I tried (in irb):
require 'daemons'
=>true
task_handle = Daemons.call do
loop{
sleep 10
puts "foo"
}
end
=> #<Daemons::Application:0x000000043f96d0 ...
task_handle.stop
=> nil
task_handle2 = Daemons.call do
loop{
sleep 10
puts "bar"
}
end
=>Daemons::RuntimeException: there is already one or more instance(s) of the program running
from /home/bdares/.rvm/gems/ruby-1.9.3-p194/gems/daemons-1.1.9/lib/daemons/application_group.rb:125:in `new_application'
from /home/bdares/.rvm/gems/ruby-1.9.3-p194/gems/daemons-1.1.9/lib/daemons.rb:251:in `call'
from (irb):21
Now, the exact example (#3 on the linked page) I'm looking at makes the first call with the option :multiple => true
, but I really only need one daemon to be running at a time (and multiple ones would, in fact, be undesirable).
Is the first daemon still somehow alive and not being GC'd? If so, what am I missing?