SKALE-4005 procceed errors

parent accfcb7e
......@@ -121,6 +121,7 @@ int CSRManagerServer::initCSRManagerServer() {
if (!cs->StartListening()) {
spdlog::info("CSR manager server could not start listening");
ExitHandler::exitHandler(SIGTERM, ExitHandler::ec_error_starting_server);
return 1;
} else {
spdlog::info("CSR manager server started on port {}", BASE_PORT + 2);
}
......@@ -130,7 +131,7 @@ int CSRManagerServer::initCSRManagerServer() {
int CSRManagerServer::exitServer() {
spdlog::info("Stoping CSRManager server");
if (!cs->StopListening()) {
if (cs && !cs->StopListening()) {
spdlog::error("CSRManager server could not be stopped");
exit(-104);
} else {
......
#include <chrono>
#include <thread>
#include "ExitHandler.h"
void ExitHandler::exitHandler( int s ) {
......@@ -10,8 +13,8 @@ void ExitHandler::exitHandler( int s, ExitHandler::exit_code_t ec ) {
g_ec = ec;
}
s_shouldExit = true;
// // HACK wait for loop in main to send exit call to consensus et al.
// std::this_thread::sleep_for( std::chrono::milliseconds( 2000 ) );
// HACK wait for loop in main to recieve exit call
std::this_thread::sleep_for( std::chrono::seconds( 20 ) );
}
volatile bool ExitHandler::s_shouldExit = false;
......
......@@ -117,6 +117,7 @@ int SGXInfoServer::initInfoServer(uint32_t _logLevel, bool _autoSign, bool _chec
if (!server->StartListening()) {
spdlog::error("Info server could not start listening on port {}", BASE_PORT + 4);
ExitHandler::exitHandler(SIGTERM, ExitHandler::ec_error_starting_server);
return 1;
} else {
spdlog::info("Info server started on port {}", BASE_PORT + 4);
}
......@@ -127,7 +128,7 @@ int SGXInfoServer::initInfoServer(uint32_t _logLevel, bool _autoSign, bool _chec
int SGXInfoServer::exitServer() {
spdlog::info("Stoping SGXInfo server");
if (!server->StopListening()) {
if (server && !server->StopListening()) {
spdlog::error("SGXInfo server could not be stopped");
exit(-105);
} else {
......
......@@ -174,6 +174,7 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
if (!server->StartListening()) {
spdlog::error("Registration server could not start listening on port {}", BASE_PORT + 1);
ExitHandler::exitHandler(SIGTERM, ExitHandler::ec_error_starting_server);
return 1;
} else {
spdlog::info("Registration server started on port {}", BASE_PORT + 1);
}
......@@ -184,7 +185,7 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
int SGXRegistrationServer::exitServer() {
spdlog::info("Stoping registration server");
if (!server->StopListening()) {
if (server && !server->StopListening()) {
spdlog::error("Registration server could not be stopped");
exit(-102);
} else {
......
......@@ -222,7 +222,7 @@ int SGXWalletServer::initHttpServer() { //without ssl
int SGXWalletServer::exitServer() {
spdlog::info("Stoping sgx server");
if (!server->StopListening()) {
if (server && !server->StopListening()) {
spdlog::error("Sgx server could not be stopped");
exit(-103);
} else {
......
......@@ -212,9 +212,15 @@ void initAll(uint32_t _logLevel, bool _checkCert,
spdlog::info("Inited JSON-RPC server over HTTP");
}
SGXRegistrationServer::initRegistrationServer(_autoSign);
CSRManagerServer::initCSRManagerServer();
SGXInfoServer::initInfoServer(_logLevel, _checkCert, _autoSign, _generateTestKeys);
if (SGXRegistrationServer::initRegistrationServer(_autoSign)) {
return;
}
if (CSRManagerServer::initCSRManagerServer()) {
return;
}
if (SGXInfoServer::initInfoServer(_logLevel, _checkCert, _autoSign, _generateTestKeys)) {
return;
}
ZMQServer::initZMQServer(_checkZMQSig);
sgxServerInited = true;
......
......@@ -72,7 +72,7 @@ void ZMQServer::run() {
auto port = BASE_PORT + 5;
spdlog::info("Starting zmq server on port {} ...", port);
spdlog::info("Starting zmq server on port {} ...", port);
try {
CHECK_STATE(frontend);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment