Fixed doctor health checks
This commit is contained in:
parent
fa0216cd6d
commit
fe29e58f22
|
@ -73,7 +73,7 @@ App::post('/v1/projects')
|
|||
->inject('dbForConsole')
|
||||
->inject('cache')
|
||||
->inject('pools')
|
||||
->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Cache $cache, Group $pools) {
|
||||
->action(function (string $projectId, string $name, string $teamId, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Cache $cache, Group $pools) {
|
||||
$team = $dbForConsole->getDocument('teams', $teamId);
|
||||
|
||||
if ($team->isEmpty()) {
|
||||
|
|
|
@ -658,11 +658,7 @@ $register->set('pools', function () {
|
|||
Config::setParam('pools-'.$key, $config);
|
||||
}
|
||||
|
||||
Console::log('Filling pools...');
|
||||
|
||||
$group->fill();
|
||||
|
||||
Console::success('Pools are ready.');
|
||||
|
||||
return $group;
|
||||
});
|
||||
|
|
|
@ -8,6 +8,7 @@ use Utopia\Storage\Device\Local;
|
|||
use Utopia\Storage\Storage;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Domains\Domain;
|
||||
|
||||
$cli
|
||||
|
@ -21,7 +22,7 @@ $cli
|
|||
|
||||
Console::log("\n" . '👩⚕️ Running ' . APP_NAME . ' Doctor for version ' . App::getEnv('_APP_VERSION', 'UNKNOWN') . ' ...' . "\n");
|
||||
|
||||
Console::log('Checking for production best practices...');
|
||||
Console::log('[Settings]');
|
||||
|
||||
$domain = new Domain(App::getEnv('_APP_DOMAIN'));
|
||||
|
||||
|
@ -90,32 +91,54 @@ $cli
|
|||
\sleep(0.2);
|
||||
|
||||
try {
|
||||
Console::log("\n" . 'Checking connectivity...');
|
||||
Console::log("\n" . '[Connectivity]');
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
}
|
||||
|
||||
try {
|
||||
$dbPool = $register->get('dbPool'); /* @var $dbPool Pools */
|
||||
$database = $dbPool->getConsoleDB();
|
||||
$pdo = $dbPool->getPDO($database);
|
||||
Console::success('Database............connected 👍');
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Database.........disconnected 👎');
|
||||
$pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */
|
||||
$configs = [
|
||||
'Console.DB' => Config::getParam('pools-console'),
|
||||
'Projects.DB' => Config::getParam('pools-database'),
|
||||
];
|
||||
|
||||
foreach ($configs as $key => $config) {
|
||||
foreach ($config as $database) {
|
||||
$adapter = $pools->get($database)->pop()->getResource();
|
||||
|
||||
try {
|
||||
if($adapter->ping()) {
|
||||
Console::success('🟢 '.str_pad("{$key}({$database})", 50, '.').'connected');
|
||||
} else {
|
||||
Console::error('🔴 '.str_pad("{$key}({$database})", 47, '.').'disconnected');
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('🔴 '.str_pad("{$key}.({$database})", 47, '.').'disconnected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$register->get('cache');
|
||||
Console::success('Queue...............connected 👍');
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Queue............disconnected 👎');
|
||||
}
|
||||
$pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */
|
||||
$configs = [
|
||||
'Cache' => Config::getParam('pools-cache'),
|
||||
'Queue' => Config::getParam('pools-queue'),
|
||||
'PubSub' => Config::getParam('pools-pubsub'),
|
||||
];
|
||||
|
||||
try {
|
||||
$register->get('cache');
|
||||
Console::success('Cache...............connected 👍');
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Cache............disconnected 👎');
|
||||
foreach ($configs as $key => $config) {
|
||||
foreach ($config as $pool) {
|
||||
$adapter = $pools->get($pool)->pop()->getResource();
|
||||
|
||||
try {
|
||||
if($adapter->ping()) {
|
||||
Console::success('🟢 '.str_pad("{$key}({$pool})", 50, '.').'connected');
|
||||
} else {
|
||||
Console::error('🔴 '.str_pad("{$key}({$pool})", 47, '.').'disconnected');
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('🔴 '.str_pad("{$key}({$pool})", 47, '.').'disconnected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled
|
||||
|
@ -126,12 +149,12 @@ $cli
|
|||
);
|
||||
|
||||
if ((@$antivirus->ping())) {
|
||||
Console::success('Antivirus...........connected 👍');
|
||||
Console::success('🟢 '.str_pad("Antivirus", 50, '.').'connected');
|
||||
} else {
|
||||
Console::error('Antivirus........disconnected 👎');
|
||||
Console::error('🔴 '.str_pad("Antivirus", 47, '.').'disconnected');
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Antivirus........disconnected 👎');
|
||||
Console::error('🔴 '.str_pad("Antivirus", 47, '.').'disconnected');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,35 +167,35 @@ $cli
|
|||
$mail->AltBody = 'Hello World';
|
||||
|
||||
$mail->send();
|
||||
Console::success('SMTP................connected 👍');
|
||||
Console::success('🟢 '.str_pad("SMTP", 50, '.').'connected');
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('SMTP.............disconnected 👎');
|
||||
Console::error('🔴 '.str_pad("SMTP", 47, '.').'disconnected');
|
||||
}
|
||||
|
||||
$host = App::getEnv('_APP_STATSD_HOST', 'telegraf');
|
||||
$port = App::getEnv('_APP_STATSD_PORT', 8125);
|
||||
|
||||
if ($fp = @\fsockopen('udp://' . $host, $port, $errCode, $errStr, 2)) {
|
||||
Console::success('StatsD..............connected 👍');
|
||||
Console::success('🟢 '.str_pad("StatsD", 50, '.').'connected');
|
||||
\fclose($fp);
|
||||
} else {
|
||||
Console::error('StatsD...........disconnected 👎');
|
||||
Console::error('🔴 '.str_pad("StatsD", 47, '.').'disconnected');
|
||||
}
|
||||
|
||||
$host = App::getEnv('_APP_INFLUXDB_HOST', '');
|
||||
$port = App::getEnv('_APP_INFLUXDB_PORT', '');
|
||||
|
||||
if ($fp = @\fsockopen($host, $port, $errCode, $errStr, 2)) {
|
||||
Console::success('InfluxDB............connected 👍');
|
||||
Console::success('🟢 '.str_pad("InfluxDB", 50, '.').'connected');
|
||||
\fclose($fp);
|
||||
} else {
|
||||
Console::error('InfluxDB.........disconnected 👎');
|
||||
Console::error('🔴 '.str_pad("InfluxDB", 47, '.').'disconnected');
|
||||
}
|
||||
|
||||
\sleep(0.2);
|
||||
|
||||
Console::log('');
|
||||
Console::log('Checking volumes...');
|
||||
Console::log('[Volumes]');
|
||||
|
||||
foreach (
|
||||
[
|
||||
|
@ -200,7 +223,7 @@ $cli
|
|||
\sleep(0.2);
|
||||
|
||||
Console::log('');
|
||||
Console::log('Checking disk space usage...');
|
||||
Console::log('[Disk Space]');
|
||||
|
||||
foreach (
|
||||
[
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
"utopia-php/abuse": "0.14.*",
|
||||
"utopia-php/analytics": "0.2.*",
|
||||
"utopia-php/audit": "0.15.*",
|
||||
"utopia-php/cache": "0.7.*",
|
||||
"utopia-php/cache": "0.8.*",
|
||||
"utopia-php/cli": "0.13.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "dev-feat-update-cache-lib as 0.26.1",
|
||||
|
|
24
composer.lock
generated
24
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "030dfcfbea2caebad080edbf048b87cf",
|
||||
"content-hash": "f3beee3a829a19e53b311052111bde2c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -1897,16 +1897,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/cache.git",
|
||||
"reference": "cd53431242c88299daea2589e21322abe97682cc"
|
||||
"reference": "212e66100a1f32e674fca5d9bc317cc998303089"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/cd53431242c88299daea2589e21322abe97682cc",
|
||||
"reference": "cd53431242c88299daea2589e21322abe97682cc",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/212e66100a1f32e674fca5d9bc317cc998303089",
|
||||
"reference": "212e66100a1f32e674fca5d9bc317cc998303089",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1940,9 +1940,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/cache/issues",
|
||||
"source": "https://github.com/utopia-php/cache/tree/0.7.0"
|
||||
"source": "https://github.com/utopia-php/cache/tree/0.8.0"
|
||||
},
|
||||
"time": "2022-10-16T06:04:12+00:00"
|
||||
"time": "2022-10-16T16:48:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cli",
|
||||
|
@ -2054,12 +2054,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "1ebee3c10a6112ab5665681f2d64f7381d3218b2"
|
||||
"reference": "44ae47dfd49c9c7c0cba29f6867347e25c23b57b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/1ebee3c10a6112ab5665681f2d64f7381d3218b2",
|
||||
"reference": "1ebee3c10a6112ab5665681f2d64f7381d3218b2",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/44ae47dfd49c9c7c0cba29f6867347e25c23b57b",
|
||||
"reference": "44ae47dfd49c9c7c0cba29f6867347e25c23b57b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2068,7 +2068,7 @@
|
|||
"ext-redis": "*",
|
||||
"mongodb/mongodb": "1.8.0",
|
||||
"php": ">=8.0",
|
||||
"utopia-php/cache": "0.7.*",
|
||||
"utopia-php/cache": "0.8.*",
|
||||
"utopia-php/framework": "0.*.*"
|
||||
},
|
||||
"require-dev": {
|
||||
|
@ -2100,7 +2100,7 @@
|
|||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/feat-update-cache-lib"
|
||||
},
|
||||
"time": "2022-10-16T09:47:14+00:00"
|
||||
"time": "2022-10-16T17:35:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
|
Loading…
Reference in a new issue