Laravel Queues in Action (2nd edition) is now available!

Ensuring Horizon terminates gracefully

Updated: Jan 2, 2020 — 1 min Read#quick-dip #horizon

One of the useful features of Laravel Horizon is its ability to gracefully shutdown, that means it'll wait for any running jobs to finish before the processes are terminated.

However, in order to really guarantee that your jobs won't be interrupted you need to make sure of the following:

  1. Your Horizon supervisors' timeout value is greater than the number of seconds consumed by the longest running job.
  2. Your job-specific timeout is shorter than the timeout value of the Horizon supervisor.
  3. If you're using Supervisor to monitor the Horizon process, make sure the value of stopwaitsecs is greater than the number of seconds consumed by the longest running job.

With this correctly configured, Supervisor will wait for the Horizon process to terminate and won't force-terminate it after stopwaitsecs passes.

Horizon supervisors will also wait for the longest job to finish running and won't force-terminate after the timeout value passes.

Hey! 👋 If you find this content useful, consider sponsoring me on GitHub.

You can also follow me on Twitter, I regularly post about all things Laravel including my latest video tutorials and blog posts.

By Mohamed Said

Hello! I'm a former Laravel core team member & VP of Engineering at Foodics. In this publication, I share everything I know about Laravel's core, packages, and tools.

You can find me on Twitter and Github.

This site was built using Wink. Follow the RSS Feed.