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
Asked
Active
Viewed 241 times
2 Answers
0
As neo4j is operated by HTTP REST interface, you just need to check if the appropriate host is reachable:
if (@fopen("http://localhost:7474/db/data/","r")) {
// database is up
}
(assuming it's running on localhost)

Ivan Skalauh
- 319
- 2
- 12
0
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
}

Christophe Willemsen
- 19,399
- 2
- 29
- 36
-
christophe-willemsen Can I check it without run a query ? – iit2011081 Mar 16 '17 at 12:48
-
The only way is to try to connect to the neo4j server. So or you make a simple http request to it manually or you issue a query – Christophe Willemsen Mar 16 '17 at 15:22