Skip to content

Commit 67498d8

Browse files
Increase the max execution time and memory limit
1 parent 96d79b8 commit 67498d8

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/Controllers/ScheduledJobController.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,39 @@ class ScheduledJobController extends BaseController
1515
use DispatchesJobs;
1616
use ValidatesRequests;
1717

18+
/**
19+
* Increase the max execution time when handling a queued job.
20+
*/
21+
protected function increaseExecutionTime(): void
22+
{
23+
ini_set('max_execution_time', 0);
24+
set_time_limit(0);
25+
}
26+
27+
/**
28+
* Increase the memory limit when handling a queued job.
29+
*/
30+
protected function increaseMemoryLimit(): void
31+
{
32+
ini_set('memory_limit', '-1');
33+
}
34+
1835
/**
1936
* Handle scheduled job event invocation.
2037
*
2138
* @return \Illuminate\Http\JsonResponse
2239
*/
2340
public function index(): JsonResponse
2441
{
42+
$this->increaseExecutionTime();
43+
$this->increaseMemoryLimit();
44+
2545
Artisan::call('schedule:run');
2646

27-
return response()->json(['info' => 'The scheduled job has completed.']);
47+
$response = [
48+
'info' => 'The scheduled job has completed.',
49+
];
50+
51+
return response()->json($reponse);
2852
}
2953
}

0 commit comments

Comments
 (0)