- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
76 lines
2.2 KiB
PHP
76 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Database\Monitoring\Dashboard;
|
|
|
|
use App\Framework\Database\DatabaseManager;
|
|
use App\Framework\Database\Monitoring\Health\DatabaseHealthChecker;
|
|
use App\Framework\Http\Controller;
|
|
use App\Framework\Http\Response\JsonResponse;
|
|
use App\Framework\Http\Response\Response;
|
|
use App\Framework\Http\Response\ViewResponse;
|
|
use App\Framework\View\ViewRenderer;
|
|
|
|
/**
|
|
* Controller for the database health dashboard
|
|
*/
|
|
final readonly class DatabaseHealthController implements Controller
|
|
{
|
|
public function __construct(
|
|
private DatabaseManager $databaseManager,
|
|
private DatabaseHealthChecker $healthChecker,
|
|
private ViewRenderer $viewRenderer
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Dashboard home page
|
|
*/
|
|
#[Route('/admin/database/health', name: 'database_health')]
|
|
public function dashboard(): Response
|
|
{
|
|
$connections = $this->databaseManager->getConnectionNames();
|
|
|
|
return new ViewResponse(
|
|
$this->viewRenderer->render('admin/database/health', [
|
|
'connections' => $connections,
|
|
])
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get health check results for a specific connection
|
|
*/
|
|
#[Route('/admin/database/health/{connection}', name: 'database_health_connection')]
|
|
public function connectionHealth(string $connection = 'default'): Response
|
|
{
|
|
if (! $this->databaseManager->hasConnection($connection)) {
|
|
return new JsonResponse([
|
|
'error' => "Connection '{$connection}' not found",
|
|
], 404);
|
|
}
|
|
|
|
$result = $this->healthChecker->checkHealth($connection);
|
|
|
|
return new JsonResponse($result->toArray());
|
|
}
|
|
|
|
/**
|
|
* Get health check results for all connections
|
|
*/
|
|
#[Route('/admin/database/health/all', name: 'database_health_all')]
|
|
public function allConnectionsHealth(): Response
|
|
{
|
|
$connections = $this->databaseManager->getConnectionNames();
|
|
$results = [];
|
|
|
|
foreach ($connections as $connection) {
|
|
$result = $this->healthChecker->checkHealth($connection);
|
|
$results[$connection] = $result->toArray();
|
|
}
|
|
|
|
return new JsonResponse($results);
|
|
}
|
|
}
|