Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Status/Health.php
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | private function checkRedis() | ||||
} catch (\Exception $exception) { | } catch (\Exception $exception) { | ||||
$this->line($exception); | $this->line($exception); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
private function checkMeet() | private function checkMeet() | ||||
{ | { | ||||
try { | |||||
$urls = \config('meet.api_urls'); | $urls = \config('meet.api_urls'); | ||||
$success = true; | |||||
foreach ($urls as $url) { | foreach ($urls as $url) { | ||||
$this->line("Checking $url"); | $this->line("Checking $url"); | ||||
try { | |||||
$client = new \GuzzleHttp\Client( | $client = new \GuzzleHttp\Client( | ||||
[ | [ | ||||
'http_errors' => false, // No exceptions from Guzzle | 'http_errors' => false, // No exceptions from Guzzle | ||||
'base_uri' => $url, | 'base_uri' => $url, | ||||
'verify' => \config('meet.api_verify_tls'), | 'verify' => \config('meet.api_verify_tls'), | ||||
'headers' => [ | 'headers' => [ | ||||
'X-Auth-Token' => \config('meet.api_token'), | 'X-Auth-Token' => \config('meet.api_token'), | ||||
], | ], | ||||
'connect_timeout' => 10, | 'connect_timeout' => 10, | ||||
'timeout' => 10, | 'timeout' => 10, | ||||
'on_stats' => function (\GuzzleHttp\TransferStats $stats) { | 'on_stats' => function (\GuzzleHttp\TransferStats $stats) { | ||||
$threshold = \config('logging.slow_log'); | $threshold = \config('logging.slow_log'); | ||||
if ($threshold && ($sec = $stats->getTransferTime()) > $threshold) { | if ($threshold && ($sec = $stats->getTransferTime()) > $threshold) { | ||||
$url = $stats->getEffectiveUri(); | $url = $stats->getEffectiveUri(); | ||||
$method = $stats->getRequest()->getMethod(); | $method = $stats->getRequest()->getMethod(); | ||||
\Log::warning(sprintf("[STATS] %s %s: %.4f sec.", $method, $url, $sec)); | \Log::warning(sprintf("[STATS] %s %s: %.4f sec.", $method, $url, $sec)); | ||||
} | } | ||||
}, | }, | ||||
] | ] | ||||
); | ); | ||||
$response = $client->request('GET', "ping"); | $response = $client->request('GET', "ping"); | ||||
if ($response->getStatusCode() != 200) { | if ($response->getStatusCode() != 200) { | ||||
$this->line("Backend not available: " . var_export($response, true)); | $this->line("Backend {$url} not available. Status: {$response->getStatusCode()} Reason: {$response->getReasonPhrase()}"); | ||||
return false; | $success = false; | ||||
} | |||||
} | } | ||||
return true; | |||||
} catch (\Exception $exception) { | } catch (\Exception $exception) { | ||||
$this->line("Backend {$url} not available:"); | |||||
$this->line($exception); | $this->line($exception); | ||||
return false; | $success = false; | ||||
} | |||||
} | } | ||||
return $success; | |||||
} | } | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
Show All 26 Lines |