solid_queue icon indicating copy to clipboard operation
solid_queue copied to clipboard

`monitor_solid_queue` not working on Puma Plugin

Open K0H205 opened this issue 1 year ago • 0 comments

Hi🖐️ I'm using the puma plugin to start a solid_queue supervisor. To make sure that puma is monitoring the supervisor, I kill the supervisor process, but the puma process does not terminate. Possible causes, In the solid_queue puma plugin, the registration to the background is done in the hook of the boot event, and puma executes the function registered in the background before boot, so I think that monitor_solid_queue is not being executed. https://github.com/rails/solid_queue/blob/1d41b530048f3d3ccdbe83cdbe4c8cbe3543dd32/lib/puma/plugin/solid_queue.rb#L17

If the registration to the background was done outside of the boot event hook, monitor_solid_queue seemed to be executed.

  def start(launcher)
    @log_writer = launcher.log_writer
    @puma_pid = $$

    launcher.events.on_booted do
      @solid_queue_pid = fork do
        Thread.new { monitor_puma }
        SolidQueue::Supervisor.start(mode: :all)
      end
    end

    launcher.events.on_stopped { stop_solid_queue }
    launcher.events.on_restart { stop_solid_queue }

    in_background do
      monitor_solid_queue
    end
  end

Solid Queue: 0.3.0 Ruby: 3.2.2 Puma: 6.4.2

Thanks

K0H205 avatar May 08 '24 11:05 K0H205