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'
timeout
value is greater than the number of seconds consumed by the longest running job. - Your job-specific
timeout
is shorter than thetimeout
value of the Horizon supervisor. - 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.