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:
- Your Horizon supervisors'
timeoutvalue is greater than the number of seconds consumed by the longest running job.
- Your job-specific
timeoutis shorter than the
timeoutvalue of the Horizon supervisor.
- If you're using Supervisor to monitor the Horizon process, make sure the value of
stopwaitsecsis 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
Horizon supervisors will also wait for the longest job to finish running and won't force-terminate after the
timeout value passes.