command('cache:blade-views') ->everyTenMinutes() ->withoutOverlapping(10); // CheckNDTReminders command removed - outdated checks (overdue, report missing, results pending) // Notification checks - Run every 5 minutes (real-time notifications) // All commands use incremental checking: first run scans all records, subsequent runs only check new records // Log when schedule:run starts $schedule->call(function () { logSchedulerExecution('schedule_run_started', [ 'run_time' => now()->toDateTimeString(), ]); })->name('schedule-run-logger')->everyMinute()->withoutOverlapping(1); // Helper function to add logging to scheduled commands $addScheduledCommand = function($command, $schedule, $scheduleMethod, ...$args) { $event = $schedule->command($command); // Apply schedule method (everyFiveMinutes, cron, etc.) if (method_exists($event, $scheduleMethod)) { $event = $event->$scheduleMethod(...$args); } // Send output to log file instead of /dev/null // This ensures before/after callbacks work correctly $logFile = storage_path('logs/scheduler-' . date('Y-m-d') . '.log'); $event->sendOutputTo($logFile); $event->appendOutputTo($logFile); // Add before callback to log when command is scheduled to run $event->before(function () use ($command) { logSchedulerExecution('command_scheduled', [ 'command' => $command, 'scheduled_time' => now()->toDateTimeString(), ]); }); // Add after callback to log when command finishes $event->after(function () use ($command) { logSchedulerExecution('command_finished', [ 'command' => $command, 'finished_time' => now()->toDateTimeString(), ]); }); return $event; }; $addScheduledCommand('notifications:check-deleted-joints', $schedule, 'everyFiveMinutes') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-repair-log-new-joint', $schedule, 'everyFiveMinutes') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-daily-repair-rate', $schedule, 'everyFiveMinutes') ->withoutOverlapping(10); // --- Batch 2 (Minutes: 1, 6, 11, 16...) --- $addScheduledCommand('notifications:check-line-list-missing-data', $schedule, 'cron', '1-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-pdf-documents', $schedule, 'cron', '1-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-weldlog-certificate', $schedule, 'cron', '1-59/5 * * * *') ->withoutOverlapping(10); // --- Batch 3 (Minutes: 2, 7, 12, 17...) --- $addScheduledCommand('notifications:check-incoming-control-certificate', $schedule, 'cron', '2-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-nde-matrix-discrepancies', $schedule, 'cron', '2-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-ndt-calculation', $schedule, 'cron', '2-59/5 * * * *') ->withoutOverlapping(10); // --- Batch 4 (Minutes: 3, 8, 13, 18...) --- $addScheduledCommand('notifications:check-manage-ndt-unnecessary', $schedule, 'cron', '3-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-support-log-weldlog', $schedule, 'cron', '3-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-paint-system-values', $schedule, 'cron', '3-59/5 * * * *') ->withoutOverlapping(10); // --- Batch 5 (Minutes: 4, 9, 14, 19...) --- $addScheduledCommand('notifications:check-weldlog-test-dates', $schedule, 'cron', '4-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-ndt-request-overdue', $schedule, 'cron', '4-59/5 * * * *') ->withoutOverlapping(10); $addScheduledCommand('notifications:check-test-log-pdf', $schedule, 'cron', '4-59/5 * * * *') ->withoutOverlapping(10); // Calibration notifications - due within 20 days (run in same batch) $addScheduledCommand('notifications:check-calibration-due', $schedule, 'cron', '4-59/5 * * * *') ->withoutOverlapping(10); $schedule->command('summary:calculation') ->hourly() ->withoutOverlapping(10); // NAKS Multi-Module Cross-Site Sync - Run daily at 02:00 // Synchronizes all NAKS data (certificates, welders, consumables, experts, equipment) // from all project sites $schedule->command('naks:sync --module=all') ->hourly() ->withoutOverlapping(120) ->appendOutputTo(storage_path('logs/naks-sync.log')); $schedule->command('telescope:prune')->daily(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }