Skip to content

Commit

Permalink
Scheduler monitoring added
Browse files Browse the repository at this point in the history
  • Loading branch information
ttimot24 committed Oct 2, 2024
1 parent 055f0ab commit 3857e0a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{

\Settings::where('setting', 'scheduler')->update(['value' => 'running']);


if(\App\HorizontCMS::isInstalled()){
foreach(\App\Model\ScheduledTask::where('active',1)->get() as $task){
$schedule->command($task->command.' '.$task->arguments)->cron($task->frequency)->before(function() use ($task) {


$jobs = \App\Model\ScheduledTask::where('active',1)->get();

\Settings::where('setting', 'scheduler')->update(['value' => uniqid("running-")."-jobs-".$jobs->count(), 'updated_at' => \Carbon\Carbon::now()]);

foreach($jobs as $task){
$schedule->command($task->command.' '.$task->arguments)->cron($task->frequency)
->before(function() use ($task) {
\Log::info("Scheduled run : ".$task->name." [".$task->command."]");
})->pingBefore(empty($task->ping_before)? 'google.com' : $task->ping_before)->thenPing(empty($task->ping_after)? 'google.com' : $task->ping_after)->withoutOverlapping();
})
->pingBefore(empty($task->ping_before)? 'google.com' : $task->ping_before)->thenPing(empty($task->ping_after)? 'google.com' : $task->ping_after)->withoutOverlapping();
}
}
}
Expand Down

0 comments on commit 3857e0a

Please sign in to comment.