php Laravel 队列进程超时错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25877752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:01:23  来源:igfitidea点击:

Laravel queue process timeout error

phpsymfonylaraveltimeoutqueue

提问by Will Durney

I'm on Laravel using php artisan queue:listento run queued jobs. One of these jobs is fairly involved and takes a long time, and so I'm getting the following error:

我在 Laravel 上php artisan queue:listen用于运行排队作业。其中一项工作相当复杂,需要很长时间,所以我收到以下错误:

[Symfony\Component\Process\Exception\ProcessTimedOutException]                                                                                                                                                                              
The process ""/usr/local/Cellar/php55/5.5.14/bin/php" artisan queue:work  
--queue="QUEUE_URL" --delay=0 --memory=128 --sleep=3 --tries=0" 
exceeded the timeout of 60 seconds.

I know that I could run queue:listenwith an arbitrarily high timeout value, but that's not ideal, as I dowant it to time out in the event that some process is actuallyunreseponsive. I tried regularly calling set_time_limit(60)within the function called by the job, but that did not solve my problem.

我知道我可以queue:listen使用任意高的超时值运行,但这并不理想,因为我确实希望它在某些进程实际上没有响应的情况下超时。我尝试set_time_limit(60)在作业调用的函数内定期调用,但这并没有解决我的问题。

I found a thread online mentioning Symfony\Component\Process\Process->setTimeout(null), but I don't know how to access that process object, or if that would even fix the issue.

我在网上找到了一个提到 的线程Symfony\Component\Process\Process->setTimeout(null),但我不知道如何访问该进程对象,或者这是否可以解决问题。

Any help would be much appreciated.

任何帮助将非常感激。

回答by David Lemayian

Adding --timeout=0worked for my set up.

添加--timeout=0适用于我的设置。

UPDATE:The entire command would therefore be php artisan queue:listen --timeout=0.

更新:因此整个命令将是php artisan queue:listen --timeout=0.

Hope this helps.

希望这可以帮助。

回答by Mostafa Lavaei

This is a known bugin Laravel v5.3:

这是Laravel v5.3 中的一个已知错误

You should upgrade to v5.5 to fix this problem.

您应该升级到 v5.5 来解决这个问题。

Another way is hacking the source code as explained here

另一种方法是破解源代码,如解释here

回答by Anmol Mourya

After investing much time I got the solution

在投入了大量时间后,我得到了解决方案

Add below line in Job class and your job run without time out, even if you put the job in a crontab entry

在 Job 类中添加以下行,即使您将作业放在 crontab 条目中,您的作业也不会超时运行

public $timeout = 0;