daemons icon indicating copy to clipboard operation
daemons copied to clipboard

:monitor & :multiple options don't work well together

Open thuehlinger opened this issue 11 years ago • 4 comments

When :monitor & :multiple are both set to true, and multiple daemon processes are started, only one monitor process gets started. And if the daemon processes crashes, only one of them gets restarted.

Source: http://stackoverflow.com/questions/14515250/daemons-do-not-get-restarted

thuehlinger avatar May 18 '14 17:05 thuehlinger

The SO post has a great description of the issue. Do you think it's better to try and match the rbX.pid files with the monitors, or simply disable :multiple+:monitor with an error message?

sodabrew avatar May 19 '14 03:05 sodabrew

What if the :multiple option can be an integer, or add a new option like :count or :num_workers?

sodabrew avatar Jun 10 '14 12:06 sodabrew

What is the status here? The issue is set to milestone 1.3.0 and latest version is 1.3.1, but the issue is still open.

adamruzicka avatar Sep 13 '19 16:09 adamruzicka

Related: :monitor + :multiple results in zombie processes.

@applications = (1..5).map do |i|
  Daemons.call(monitor: true, multiple: true, **some_other_options) do
    loop do
      if rand(5) == 0
        abort "Daemon #{i} stopping"
      else
        puts "Daemon #{i} still alive"
        sleep 1
      end
    end
  end
end

sleep 30
@applications.each(&:stop)

This will result in the Monitor restarting some of the daemons, but they won't be in @applications and will run forever. You can fix this by reaching through the Application to its ApplicationGroup:

@applications.each { |app| app.group.stop_all }

jamesarosen avatar Dec 16 '21 19:12 jamesarosen