Skip to content

Commit

Permalink
Create a console kernel instance before running webcron
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpar06 committed May 24, 2024
1 parent 6d5684f commit 0a94d5b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/Http/Controllers/Api/MaintenanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api;

use App\Console\Cron;
use App\Console\Kernel;
use App\Contracts\Controller;
use App\Exceptions\CronInvalid;
use Illuminate\Http\JsonResponse;
Expand All @@ -25,6 +26,15 @@ public function cron(Request $request, string $id): JsonResponse
throw new CronInvalid();
}

// Create a console kernel instance
$consoleKernel = app()->make(Kernel::class);

// Run a null artisan thing just so Laravel internals can be setup properly
$status = $consoleKernel->handle(
new \Symfony\Component\Console\Input\ArgvInput(),
new \Symfony\Component\Console\Output\NullOutput()
);

$cron = app(Cron::class);
$run = $cron->run();

Expand Down

0 comments on commit 0a94d5b

Please sign in to comment.