diff --git a/config/reverb.php b/config/reverb.php index a17d7d43..2ee4bce4 100644 --- a/config/reverb.php +++ b/config/reverb.php @@ -41,6 +41,7 @@ 'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'), ], 'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15), + 'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15), ], ], diff --git a/phpstan.neon.dist b/phpstan.neon.dist index cdee4be6..7de2edab 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -13,3 +13,5 @@ parameters: - "#\\(void\\) is used.#" - "#Parameter \\$livewire of anonymous function has invalid type#" - "#Class Laravel\\\\Pulse\\\\Pulse not found#" + - "#Class Laravel\\\\Telescope\\\\Contracts\\\\EntriesRepository not found#" + - "#Call to static method store\\(\\) on an unknown class Laravel\\\\Telescope\\\\Telescope#" diff --git a/src/Servers/Reverb/Console/Commands/StartServer.php b/src/Servers/Reverb/Console/Commands/StartServer.php index c0215988..c4ba7430 100644 --- a/src/Servers/Reverb/Console/Commands/StartServer.php +++ b/src/Servers/Reverb/Console/Commands/StartServer.php @@ -67,6 +67,7 @@ public function handle(): void $this->ensureStaleConnectionsAreCleaned($loop); $this->ensureRestartCommandIsRespected($server, $loop, $host, $port); $this->ensurePulseEventsAreCollected($loop, $config['pulse_ingest_interval']); + $this->ensureTelescopeEntriesAreCollected($loop, $config['telescope_ingest_interval'] ?? 15); $this->components->info('Starting '.($server->isSecure() ? 'secure ' : '')."server on {$host}:{$port}".(($hostname && $hostname !== $host) ? " ({$hostname})" : '')); @@ -145,6 +146,20 @@ protected function ensurePulseEventsAreCollected(LoopInterface $loop, int $inter }); } + /** + * Schedule Telescope to store entries if enabled. + */ + protected function ensureTelescopeEntriesAreCollected(LoopInterface $loop, int $interval): void + { + if (! class_exists(\Laravel\Telescope\Telescope::class)) { + return; + } + + $loop->addPeriodicTimer($interval, function () { + \Laravel\Telescope\Telescope::store($this->laravel->make(\Laravel\Telescope\Contracts\EntriesRepository::class)); + }); + } + /** * Get the list of signals handled by the command. */