rails / solid_queue

Database-backed Active Job backend
MIT License
1.95k stars 130 forks source link

Starting/Stopping Specific Workers for SolidQueue #418

Closed bmb1603 closed 2 days ago

bmb1603 commented 2 days ago

Currently, if I need to update the code for a single job, I find myself restarting the entire SolidQueue system, which disrupts all running jobs. Is there any guidance on how to:

  1. Stop a worker for a specific queue.
  2. Start (or restart) it without affecting other workers.
rosa commented 2 days ago

Hey @bmb1603, you can use signals to terminate specific workers as described in the README. However, I wouldn't recommend running mixed code between workers or updating code in production without deploying your app, and in most setups, if you deploy your app, the deployment would take care of restarting all your workers (or at least it should).

bmb1603 commented 2 days ago

Thank you Rosa! So in other words SolidQueue should completely shutdown and restart with every new deployment? Which probably would happen automatically when using the whole pipeline with Kamal/etc.?

We are running SolidQueue as an Ubuntu Service. Sounds like this is the root of the issue then?

rosa commented 2 days ago

So in other words SolidQueue should completely shutdown and restart with every new deployment?

Not just Solid Queue, but any Active Job backend, otherwise you might be running old code 🤔 You might want a short period to finish in-flight jobs, but eventually you'd need to restart it.

With Kamal, depending on how you configure it, it should happen automatically, yes. You might want to check stop-wait-time.

I'm not sure about Ubuntu services or what the issue is 🤔 Is Solid Queue not getting restarted when you deploy or is it something else?