简体   繁体   中英

Laravel dispatch job run async

I have a function that posts some content and pushes a job onto a queue and returns response to user even before the queue complete the job.

for that I changed the .env QUEUE_DRIVER to database, And records is saved in table jobs, but to execute this jobs I have to call the command php artisan queue:work , and that is my question: how do I call this command in the code or what should I do whenever there is jobs in the table?

The command

php artisan:queue work

Should be runnig always it will check if there is new jobs he will dispatch them But it should be always running you can't execute it from the code Also you can run

php artisan queue:work --tries=5

This for example will try 5 times then it will stop

Plus you can install supervisor it will always start the queue:work if it faild

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM