Merge pull request #5597

343c0b4 add a command line option to disable ZMQ server (jtgrassie)
This commit is contained in:
luigi1111
2019-07-24 14:26:59 -05:00
4 changed files with 29 additions and 15 deletions

View File

@@ -105,6 +105,7 @@ t_daemon::t_daemon(
{
zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_port);
zmq_rpc_bind_address = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_ip);
zmq_rpc_disabled = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_disabled);
}
t_daemon::~t_daemon() = default;
@@ -171,25 +172,30 @@ bool t_daemon::run(bool interactive)
cryptonote::rpc::DaemonHandler rpc_daemon_handler(mp_internals->core.get(), mp_internals->p2p.get());
cryptonote::rpc::ZmqServer zmq_server(rpc_daemon_handler);
if (!zmq_server.addTCPSocket(zmq_rpc_bind_address, zmq_rpc_bind_port))
if (!zmq_rpc_disabled)
{
LOG_ERROR(std::string("Failed to add TCP Socket (") + zmq_rpc_bind_address
+ ":" + zmq_rpc_bind_port + ") to ZMQ RPC Server");
if (!zmq_server.addTCPSocket(zmq_rpc_bind_address, zmq_rpc_bind_port))
{
LOG_ERROR(std::string("Failed to add TCP Socket (") + zmq_rpc_bind_address
+ ":" + zmq_rpc_bind_port + ") to ZMQ RPC Server");
if (rpc_commands)
rpc_commands->stop_handling();
if (rpc_commands)
rpc_commands->stop_handling();
for(auto& rpc : mp_internals->rpcs)
rpc->stop();
for(auto& rpc : mp_internals->rpcs)
rpc->stop();
return false;
return false;
}
MINFO("Starting ZMQ server...");
zmq_server.run();
MINFO(std::string("ZMQ server started at ") + zmq_rpc_bind_address
+ ":" + zmq_rpc_bind_port + ".");
}
MINFO("Starting ZMQ server...");
zmq_server.run();
MINFO(std::string("ZMQ server started at ") + zmq_rpc_bind_address
+ ":" + zmq_rpc_bind_port + ".");
else
MINFO("ZMQ server disabled");
if (public_rpc_port > 0)
{
@@ -202,7 +208,8 @@ bool t_daemon::run(bool interactive)
if (rpc_commands)
rpc_commands->stop_handling();
zmq_server.stop();
if (!zmq_rpc_disabled)
zmq_server.stop();
for(auto& rpc : mp_internals->rpcs)
rpc->stop();