SSR health: alert mails on ok/down transitions + auto-failover to SPA after N consecutive misses (SSR_ALERT_EMAIL / SSR_FAILOVER_AFTER in var/vitec-ssr-purge.env)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9736b9ac7
commit
bc2e031b0c
3 files changed
+183
-2
No files matched your search
@@ -13,7 +13,8 @@ use TYPO3\CMS\Core\Http\RequestFactory;
|
||||
* keeps a log of every attempt in tx_vitec_ssrpurgelog.
|
||||
*
|
||||
* Endpoint + secret live OUTSIDE the repository in var/vitec-ssr-purge.env
|
||||
* (KEY=VALUE lines: SSR_PURGE_ENDPOINT, SSR_PURGE_SECRET, SSR_HEALTH_ENDPOINT)
|
||||
* (KEY=VALUE lines: SSR_PURGE_ENDPOINT, SSR_PURGE_SECRET, SSR_HEALTH_ENDPOINT,
|
||||
* SSR_ALERT_EMAIL, SSR_FAILOVER_AFTER)
|
||||
* - same pattern as the routing flag file, nothing secret in git.
|
||||
*/
|
||||
final class SsrPurgeService
|
||||
@@ -41,6 +42,25 @@ final class SsrPurgeService
|
||||
return $this->getConfig()['SSR_HEALTH_ENDPOINT'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Comma-separated recipient list for vitec:ssr-health transition and
|
||||
* failover alerts (SSR_ALERT_EMAIL); empty string = alerting off.
|
||||
*/
|
||||
public function getAlertEmail(): string
|
||||
{
|
||||
return trim($this->getConfig()['SSR_ALERT_EMAIL'] ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Consecutive DOWN samples after which vitec:ssr-health fails over to
|
||||
* the SPA (SSR_FAILOVER_AFTER, default 2 = ~10 minutes at the 5-minute
|
||||
* cron cadence). Never below 1.
|
||||
*/
|
||||
public function getFailoverAfter(): int
|
||||
{
|
||||
return max(1, (int)($this->getConfig()['SSR_FAILOVER_AFTER'] ?? 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes, dedupes and sends the paths; logs the outcome.
|
||||
* Never throws - editors' saves must not fail on a purge problem.
|
||||
|
||||
Reference in new issue
Block a user