douhu5837 2018-10-19 12:42
浏览 370
已采纳

Laravel Worker似乎没有停止

I have a list of jobs in my database, when I run php artisan queue:work database, it processes each job but once it processes the last one, it doesn't seem to stop. I thought doing it this way would mean once the worker has no jobs left, it stops.

  • 写回答

2条回答 默认 最新

  • doushenken2833 2018-10-19 12:48
    关注

    Add the --once option if you want the worker to exit after running one job:

    $ php artisan queue:work --once
    

    As of 5.7 you can use --stop-when-empty to process all jobs in the queue and then exit:

    $ php artisan queue:work --stop-when-empty
    

    Docs: https://laravel.com/docs/5.7/queues#running-the-queue-worker

    Note: The default behavior changed around Laravel 5.3. Previously a worker would process one job and exit; it only continued running if the --daemon option had been used. After 5.3 this became the default behavior, and --daemon was deprecated.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部