- new "ESI monitoring" UI dialog, closed #748

- new "Redis monitoring" UI on `/setup` page, closed #745
- improved request handling for 3rd party APIs (ESI, SSO, GitHub) see [exodus4d/pathfinder_esi/README.md](https://github.com/exodus4d/pathfinder_esi/blob/b5d4b19/README.md)
- improved `/setup` page, new actions for clear cache/Redis data
This commit is contained in:
Mark Friedrich
2019-02-08 15:12:53 +01:00
parent e56740e8a0
commit e28fea9081
164 changed files with 1919 additions and 1038 deletions

View File

@@ -541,34 +541,73 @@ class Controller {
* @throws \Exception
*/
public function getEveServerStatus(\Base $f3){
$cacheKey = 'eve_server_status';
if( !$f3->exists($cacheKey, $return) ){
$return = (object) [];
$return->error = [];
$return->status = [
'serverName' => strtoupper( self::getEnvironmentData('CCP_ESI_DATASOURCE') ),
'serviceStatus' => 'offline'
$esiStatusVersion = 'latest';
$return = (object) [];
$return->error = [];
if($client = $f3->ccpClient()){
$return->server = [
'name' => strtoupper( self::getEnvironmentData('CCP_ESI_DATASOURCE') ),
'status' => 'offline',
'statusColor' => 'red',
];
$return->api = [
'name' => 'ESI API',
'status' => 'offline',
'statusColor' => 'red',
'url' => $client->getUrl(),
'timeout' => $client->getTimeout(),
'connectTimeout' => $client->getConnectTimeout(),
'readTimeout' => $client->getReadTimeout(),
'proxy' => ($proxy = $client->getProxy()) ? : 'false',
'verify' => $client->getVerify(),
'debug' => $client->getDebugRequests(),
'dataSource' => $client->getDataSource(),
'statusVersion' => $esiStatusVersion,
'routes' => []
];
$response = $f3->ccpClient->getServerStatus();
if( !empty($response) ){
$serverStatus = $client->getServerStatus();
if( !isset($serverStatus['error']) ){
$statusData = $serverStatus['status'];
// calculate time diff since last server restart
$timezone = $f3->get('getTimeZone')();
$dateNow = new \DateTime('now', $timezone);
$dateServerStart = new \DateTime($response['startTime']);
$dateServerStart = new \DateTime($statusData['startTime']);
$interval = $dateNow->diff($dateServerStart);
$startTimestampFormat = $interval->format('%hh %im');
if($interval->days > 0){
$startTimestampFormat = $interval->days . 'd ' . $startTimestampFormat;
}
$response['serverName'] = strtoupper( self::getEnvironmentData('CCP_ESI_DATASOURCE') );
$response['serviceStatus'] = 'online';
$response['startTime'] = $startTimestampFormat;
$return->status = $response;
$statusData['name'] = $return->server['name'];
$statusData['status'] = 'online';
$statusData['statusColor'] = 'green';
$statusData['startTime'] = $startTimestampFormat;
$return->server = $statusData;
}
$f3->set($cacheKey, $return, 60);
$apiStatus = $client->getStatusForRoutes('latest');
if( !isset($apiStatus['error']) ){
// find top status
$status = 'OK';
$color = 'green';
foreach($apiStatus['status'] as $statusData){
if('red' == $statusData['status']){
$status = 'unstable';
$color = $statusData['status'];
break;
}
if('yellow' == $statusData['status']){
$status = 'degraded';
$color = $statusData['status'];
}
}
$return->api['status'] = $status;
$return->api['statusColor'] = $color;
$return->api['routes'] = $apiStatus['status'];
}
}
@@ -795,9 +834,8 @@ class Controller {
* @param string $authType
* @return array
*/
static function getScopesByAuthType($authType = ''){
static function getScopesByAuthType(string $authType = '') : array {
$scopes = array_filter((array)self::getEnvironmentData('CCP_ESI_SCOPES'));
switch($authType){
case 'admin':
$scopesAdmin = array_filter((array)self::getEnvironmentData('CCP_ESI_SCOPES_ADMIN'));