[英]How to close connection with cassandra with node.js
How to close connection with Cassandra in node.js? 如何在node.js中关闭与Cassandra的连接? If I didn't close the connection, I will encounter an error.
如果我没有关闭连接,将会遇到错误。 The error is Error:
错误是错误:
All host(s) tried for query failed. First host tried, 10.XXXXX:OOO: Error: connect EMFILE
I have seen the solution in datastax. 我已经在datastax中看到了解决方案。 It suggest that it could be solved by the command:
process.exit()
. 它建议可以通过以下命令解决:
process.exit()
。 But it will kill the whole node.js process. 但是它将杀死整个node.js进程。 That is not what I want.
那不是我想要的。 I just want to close the cassandra connection not the whole node.js process.
我只想关闭cassandra连接,而不是整个node.js进程。 Is there anyone has good solution to this?
有没有人对此有很好的解决方案?
You should call shutdown() before exiting: 您应该在退出之前调用shutdown() :
client.shutdown();
You can provide an optional callback. 您可以提供可选的回调。
You should only call client.shutdown()
once in your application's lifetime . 您应仅在应用程序的生存
client.shutdown()
调用client.shutdown()
一次 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.