diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-07-24 14:26:59 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-07-24 14:26:59 -0500 |
commit | 015c1792c0862ee6518cff022a16a1aeea8e7c5c (patch) | |
tree | 11049337e6e66182870de52b6dc046e4d151d1b0 /src/daemon | |
parent | Merge pull request #5595 (diff) | |
parent | add a command line option to disable ZMQ server (diff) | |
download | monero-015c1792c0862ee6518cff022a16a1aeea8e7c5c.tar.xz |
Merge pull request #5597
343c0b4 add a command line option to disable ZMQ server (jtgrassie)
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/command_line_args.h | 5 | ||||
-rw-r--r-- | src/daemon/daemon.cpp | 35 | ||||
-rw-r--r-- | src/daemon/daemon.h | 1 | ||||
-rw-r--r-- | src/daemon/main.cpp | 1 |
4 files changed, 28 insertions, 14 deletions
diff --git a/src/daemon/command_line_args.h b/src/daemon/command_line_args.h index 32fdca5ea..d089d4e47 100644 --- a/src/daemon/command_line_args.h +++ b/src/daemon/command_line_args.h @@ -122,6 +122,11 @@ namespace daemon_args } }; + const command_line::arg_descriptor<bool> arg_zmq_rpc_disabled = { + "no-zmq" + , "Disable ZMQ RPC server" + }; + } // namespace daemon_args #endif // DAEMON_COMMAND_LINE_ARGS_H diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 5084b6283..cb96b37b6 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -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("Starting ZMQ server..."); + zmq_server.run(); - MINFO(std::string("ZMQ server started at ") + zmq_rpc_bind_address - + ":" + zmq_rpc_bind_port + "."); + 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(); diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index d44173177..c0efb68ee 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -46,6 +46,7 @@ private: uint16_t public_rpc_port; std::string zmq_rpc_bind_address; std::string zmq_rpc_bind_port; + bool zmq_rpc_disabled; public: t_daemon( boost::program_options::variables_map const & vm, diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index 690d4d60e..461888062 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -141,6 +141,7 @@ int main(int argc, char const * argv[]) command_line::add_arg(core_settings, daemon_args::arg_public_node); command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_bind_ip); command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_bind_port); + command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_disabled); daemonizer::init_options(hidden_options, visible_options); daemonize::t_executor::init_options(core_settings); |