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 want to receive updates on what I'm up to, I host a newsletter on my website themsaid.com and would love to have you.

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 full-stack web developer working at Laravel. 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.