I want to send an email when my db is down. I don't know how to check neo4j is running or not from php. I am using neoxygen neoclient library to connect to neo4j. Is there any way around to do this ? I am using neo4j 2.3.2
How to check neo4j is running or not from php?
258 Views Asked by iit2011081 At
2
There are 2 best solutions below
2

a) Upgrade to graphaware neo4j-php-client, neoxygen is deprecated since months and has been ported there since more than a year.
b) You can just do a try/catch on a query :
try {
$result = $client->run('RETURN 1 AS x');
if (1 === $result->firstRecord()->get('x') { // db is running // }
} catch(\Exception $e) {
// db is not running or connection cannot be made
}
As neo4j is operated by HTTP REST interface, you just need to check if the appropriate host is reachable:
(assuming it's running on localhost)