Skip to content

Commit

Permalink
Merge pull request #22 from islamic-network/status_update
Browse files Browse the repository at this point in the history
Status update
  • Loading branch information
Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram / مِيزَانُ الْدِّينْ عَبْدُ ذِيْ الْجَلَالِ وَ الْإِكْرَامِ authored Apr 3, 2019
2 parents 0814908 + da39a9c commit 419f12b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ ENV MYSQL_USER "aladhan"
ENV MYSQL_PASSWORD "aladhan"
ENV MYSQL_DATABASE "aladhan_locations"
ENV MYSQL_HOST "db1"
ENV MYSQL_SLAVE_USER "aladhan"
ENV MYSQL_SLAVE_PASSWORD "aladhan"
ENV MYSQL_SLAVE_DATABASE "aladhan_locations"
ENV MYSQL_SLAVE_HOST "db2"
ENV MEMCACHED_HOST "host"
ENV MEMCACHED_PORT "port"
ENV GOOGLE_API_KEY "key"
Expand Down
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ services:
MYSQL_PASSWORD: "aladhan"
MYSQL_DATABASE: "aladhan_locations"
MYSQL_HOST: "aa-db"
MYSQL_SLAVE_USER: "aladhan"
MYSQL_SLAVE_PASSWORD: "aladhan"
MYSQL_SLAVE_DATABASE: "aladhan_locations"
MYSQL_SLAVE_HOST: "aa-db"
MEMCACHED_HOST: "aa-memcached"
MEMCACHED_PORT: 11211
GOOGLE_API_KEY: "xyz"
Expand Down
23 changes: 2 additions & 21 deletions routes/status/v1/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,11 @@
} catch (Exception $e) {
$dbResult = false;
}
try {
$db2 = $dbx->getConnection('database_slave');
$db2Result = $db2->fetchAssoc("SELECT id
FROM geolocate WHERE
city = ? AND countryiso = ?",
['Dubai', 'AE']);

if ($mc !== false) {
if ($dbResult !== false) {
$mc->set('DB_CONNECTION', 'database');
} else {
$mc->set('DB_CONNECTION', 'database_slave');
}
}
} catch (Exception $e) {
$db2Result = false;
}

$status = [
'memcached' => $mc === false ? 'NOT OK' : 'OK',
'perconaMaster' => $dbResult === false ? 'NOT OK' : 'OK',
'perconaSlave' => $db2Result === false ? 'NOT OK' : 'OK',
'activeDb' => $mc === false ? 'NOT OK' : $mc->get('DB_CONNECTION')
];
'galeraCluster' => $dbResult === false ? 'NOT OK' : 'OK',
];

if ($mc === false || $dbResult === false || $db2Result === false) {
return $response->withJson(ApiResponse::build($status, 500, 'Status Check Failed'), 500);
Expand Down

0 comments on commit 419f12b

Please sign in to comment.