Laravel 5.6。在与主管执行工作后停止工人

Laravel 5.6. Stop a worker AFTER job execution with supervisor

是否可以通过这种方式向工作人员发送停止信号,使其仅在处理完作业后才会停止。

目前我有一份工作,这需要一些时间而且不能被打断,因为我只有一份 try/attempt。

有时我需要停止工作人员重新部署我的代码。有没有办法在完成当前工作后开始新工作之前停止 Laravel 的工作人员?

我正在使用 supervisor 重新启动队列工作器。

因为目前每次部署我都会失去 1 个工作并且我的客户会赔钱:(

P.S.

这不是 的副本,因为他使用的是 Artisan CLI 而我使用的是 supervisor

autorestart=true in supervisor + php artisan queue:restart 解决了这个问题。

主管有一个XML-RPC Api which you could use from your php code. I sugesst you use Zend's XML-RPC Client

为此有一个内置功能:

php artisan queue:restart

This command will instruct all queue workers to gracefully "die" after they finish processing their current job so that no existing jobs are lost. Since the queue workers will die when the queue:restart command is executed, you should be running a process manager such as Supervisor to automatically restart the queue workers.