Skip to content

Commit

Permalink
Fix running wallet rpc and logging in walletd
Browse files Browse the repository at this point in the history
can possibly delete event and dispatcher from JsonRpcServer
  • Loading branch information
aivve committed May 5, 2024
1 parent d92a0f3 commit d46c0c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/JsonRpcServer/JsonRpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ void JsonRpcServer::start(const std::string& bindAddress, uint16_t bindPort, uin
}

m_workers.push_back(std::thread(std::bind(&JsonRpcServer::listen, this, bindAddress, bindPort)));

stopEvent->wait();
}

void JsonRpcServer::stop() {
Expand All @@ -71,14 +69,6 @@ void JsonRpcServer::stop() {

http->stop();

if (m_dispatcher != nullptr) {
m_dispatcher->remoteSpawn([&]() {
if (stopEvent != nullptr) {
stopEvent->set();
}
});
}

for (auto& th : m_workers) {
if (th.joinable()) {
th.join();
Expand Down
12 changes: 11 additions & 1 deletion src/PaymentGateService/PaymentGateService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,24 @@ void PaymentGateService::runWalletService(const CryptoNote::Currency& currency,

rpcServer.setAuth(config.gateConfiguration.m_rpcUser, config.gateConfiguration.m_rpcPassword);

Tools::SignalHandler::install([&rpcServer] {
Tools::SignalHandler::install([&] {
rpcServer.stop();

if (dispatcher != nullptr) {
dispatcher->remoteSpawn([&]() {
if (stopEvent != nullptr) {
stopEvent->set();
}
});
}
});

rpcServer.start(config.gateConfiguration.m_bind_address,
config.gateConfiguration.m_bind_port,
config.gateConfiguration.m_bind_port_ssl);

stopEvent->wait();

Logging::LoggerRef(logger, "PaymentGateService")(Logging::INFO, Logging::BRIGHT_WHITE) << "JSON-RPC server stopped, stopping wallet service...";

try {
Expand Down
2 changes: 1 addition & 1 deletion src/Wallet/WalletRpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ wallet_rpc_server::wallet_rpc_server(

//------------------------------------------------------------------------------------------------------------------------------

wallet_rpc_server::~wallet_rpc_server() {
wallet_rpc_server::~wallet_rpc_server() {
}

//------------------------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit d46c0c6

Please sign in to comment.