[英]How to check neo4j is running or not from php?
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.
我不知道如何从php检查neo4j是否正在运行。 I am using neoxygen neoclient library to connect to neo4j.
我正在使用neonicgen neoclient库连接到neo4j。 Is there any way around to do this ?
有什么办法可以做到这一点? I am using neo4j 2.3.2
我正在使用neo4j 2.3.2
As neo4j is operated by HTTP REST interface, you just need to check if the appropriate host is reachable: 由于neo4j由HTTP REST接口操作,因此您只需要检查适当的主机是否可访问:
if (@fopen("http://localhost:7474/db/data/","r")) {
// database is up
}
(assuming it's running on localhost) (假设它在本地主机上运行)
a) Upgrade to graphaware neo4j-php-client, neoxygen is deprecated since months and has been ported there since more than a year. a)升级到graphaware neo4j-php-client,自几个月以来不推荐使用neoxygen,并且已经从一年多开始移植了。
b) You can just do a try/catch on a query : b)您可以尝试对查询进行尝试/捕获:
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.