:monitor & :multiple options don't work well together
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
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?
What if the :multiple option can be an integer, or add a new option like :count or :num_workers?
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.
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 }