与PHP的批处理过程分离 - Laravel批处理
我有一个程序一次处理几个导入文件。问题是在1分钟之后,网关时间耗尽并杀死流程。为了解决这个问题,我正在使用批处理。它创建了批处理,唯一的问题是我不能从批处理中分离,然后返回浏览器“批处理开始”。这是我启动批处理的代码:
$files = self::prepare_files($request);
// Lets batch this call
$batch = Bus::batch([
new ImportJob($files),
])
->then(function (Batch $batch) use($files) {
//This is not really needed
})
->dispatch();
return "Batch Started";
代码启动,我可以看到它在数据库中的MySQL Job_batches表中运行并观看更新。直到批处理过程完成后,它才能达到返回语句。因此,持续5分钟的导入后,门户在1分钟后会熄灭,并且无法向前前进。如果我可以让它下车并真正在后台运行,我会做的,因为我可以返回批处理ID并让浏览器调用另一个端点以监视批处理,返回结果等
...帮助您可以为此提供借口。
I have a program that processes several import files at a time. Problem is after 1 minute the gateway times out and kills the processes. To get around this I am using batching. It creates the batch just fine the only problem is I can't detach from the batch and return back to the browser "Batch Started". Here is my code where I start the batch:
$files = self::prepare_files($request);
// Lets batch this call
$batch = Bus::batch([
new ImportJob($files),
])
->then(function (Batch $batch) use($files) {
//This is not really needed
})
->dispatch();
return "Batch Started";
The code starts up and I can see it running in the MySQL job_batches table in my database and watch it update. It doesn't hit the return statement until after the batch process finishes running. So with an import that lasts 5 minutes, the gateway times out after 1 minute and it can't move forward. If I can get it to drop off and truly run in the background I would have it made since I can return the batch ID and let the browser call another endpoint to monitor the batch, return results, etc...
Thanks in advance for any help you can lend on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论