Will Laravel queue worker exit mid execution with --max-time?

Viewed 143

In Laravel documentation, it states that --max-time will instruct the worker to process jobs for the given number of seconds and then exit. I suppose this timer starts when the queue worker is active right? In that case, if my max-time is 600 seconds, at 600 seconds mark, if there's still a job being processed, will the worker still immediately quit or it will wait for the job to finish before quitting?

1 Answers

It will wait for the job to finish before quitting.

In this post, Mohamed shows an example for this artisan call utilizing the --max-time parameter:

php artisan queue:work --max-jobs=1000 --max-time=3600

"This worker will automatically exit after processing 1000 jobs or after running for an hour. After processing each job, the worker will check if it exceeded max-jobs or max-time and then decide between exiting or picking up more jobs. The worker will not exit while in the middle of processing a job."

I am using this to avoid memory leaks in the queue workers piling up over time with large jobs.

Related