From f988a89cf3d7a1b256015b7221f7635a3a0552d2 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Fri, 15 Oct 2021 10:05:21 +0100 Subject: [PATCH] Update health.php --- app/controllers/api/health.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index cbccb8f59c..bd7721d463 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -5,6 +5,7 @@ use Utopia\Exception; use Utopia\Storage\Device\Local; use Utopia\Storage\Storage; use Appwrite\ClamAV\Network; +use Appwrite\Database\Database; use Appwrite\Event\Event; App::get('/v1/health') @@ -46,9 +47,18 @@ App::get('/v1/health/db') ->action(function ($response, $utopia) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\App $utopia */ - $utopia->getResource('db'); + $db = $utopia->getResource('db'); /* @var $db PDO */ - $response->json(['status' => 'OK']); + // Run a small test to check the connection + $statement = $db->prepare(" + SELECT 1;" + ); + + $statement->closeCursor(); + + $statement->execute(); + + return $response->json(['status' => 'OK']); }); App::get('/v1/health/cache')