c76038d076
Закрывает дыру #6 из аудита журналирования 23.05.2026. Что: * `scheduler_heartbeats` таблица (SaaS-level, PK=command_name, без RLS) * `SchedulerHeartbeatTracker` сервис — UPSERT через pgsql_supplier (BYPASSRLS), recordRun(callable) + recordRunResult(name, success, error, ms) * `routes/console.php` — 11 cron-задач обёрнуты onSuccess/onFailure хуками (минимально-инвазивно, без правки самих джобов) * `scheduler:check-heartbeats` команда — hourly МСК: - алертит при пропавшем пульсе (>2× ожидаемого интервала) - алертит при consecutive_failures >= 3 - dedup 60 мин, пишет incidents_log (severity=high) + Mail на kdv1@bk.ru * `SchedulerHeartbeatMissingMail` mailable + blade NB: используется `onSuccess()` а не `after()` — `after()` срабатывает при любом исходе и ложно обновлял бы last_success_at при failure (правильный поведенческий паттерн = onSuccess + onFailure). consecutive_failures корректно растёт через ON CONFLICT DO UPDATE +1. Schema bump v8.29→v8.30. +1 слово в cspell-words.txt (FQCN). Тесты: 8/8 passed (24 assertions, ~1.6s) — recordRun success/failure, SchedulerCheckHeartbeats missing pulse + failure spike + dedup + Mailable. Plan: docs/superpowers/plans/2026-05-23-7-holes-overview.md (#6).
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
|
|
/**
|
|
* Уведомление о пропавшем или постоянно падающем cron-задаче.
|
|
*
|
|
* Триггер: SchedulerCheckHeartbeats обнаружил:
|
|
* • отсутствие пульса > 2× ожидаемого интервала, ИЛИ
|
|
* • consecutive_failures >= 3.
|
|
*
|
|
* Отправляется на kdv1@bk.ru (monitoring email).
|
|
*/
|
|
final class SchedulerHeartbeatMissingMail extends Mailable
|
|
{
|
|
public function __construct(
|
|
public readonly string $commandName,
|
|
public readonly string $reason,
|
|
public readonly ?string $lastError,
|
|
public readonly int $consecutiveFailures,
|
|
) {}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: "[Лидерра HIGH] Scheduler heartbeat missing: {$this->commandName}",
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(
|
|
text: 'emails.scheduler_heartbeat_missing_text',
|
|
with: [
|
|
'commandName' => $this->commandName,
|
|
'reason' => $this->reason,
|
|
'lastError' => $this->lastError,
|
|
'consecutiveFailures' => $this->consecutiveFailures,
|
|
'now' => now()->timezone('Europe/Moscow')->toIso8601String(),
|
|
],
|
|
);
|
|
}
|
|
}
|