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.