Unverified Commit a51472cc authored by kladko's avatar kladko

bug/SKALE-3751-enable-zeromq

parent 40c19439
......@@ -115,6 +115,8 @@ int CSRManagerServer::initCSRManagerServer() {
hs3->BindLocalhost();
cs = make_shared<CSRManagerServer>(*hs3, JSONRPC_SERVER_V2); // server (json-rpc 2.0)
spdlog::info("Starting csr manager server on port {} ...", BASE_PORT + 2);
if (!cs->StartListening()) {
spdlog::info("CSR manager server could not start listening");
exit(-1);
......
......@@ -111,6 +111,8 @@ int SGXInfoServer::initInfoServer(uint32_t _logLevel, bool _autoSign, bool _chec
httpServer = make_shared<HttpServer>(BASE_PORT + 4);
server = make_shared<SGXInfoServer>(*httpServer, JSONRPC_SERVER_V2, _logLevel, _autoSign, _checkCerts, _generateTestKeys); // hybrid server (json-rpc 1.0 & 2.0)
spdlog::info("Starting info server on port {} ...", BASE_PORT + 4);
if (!server->StartListening()) {
spdlog::error("Info server could not start listening on port {}", BASE_PORT + 4);
exit(-10);
......
......@@ -168,6 +168,8 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
JSONRPC_SERVER_V2,
_autoSign); // hybrid server (json-rpc 1.0 & 2.0)
spdlog::info("Starting registration server on port {} ...", BASE_PORT + 1);
if (!server->StartListening()) {
spdlog::error("Registration server could not start listening on port {}", BASE_PORT + 1);
exit(-10);
......
......@@ -164,6 +164,8 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
server = make_shared<SGXWalletServer>(*httpServer,
JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
spdlog::info("Starting sgx server on port {} ...", BASE_PORT);
if (!server->StartListening()) {
spdlog::error("SGX Server could not start listening");
exit(-13);
......@@ -176,6 +178,9 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
int SGXWalletServer::initHttpServer() { //without ssl
COUNT_STATISTICS
spdlog::info("Entering {}", __FUNCTION__);
spdlog::info("Starting sgx http server on port {} ...", BASE_PORT + 3);
httpServer = make_shared<HttpServer>(BASE_PORT + 3, "", "", "", false,
NUM_THREADS);
server = make_shared<SGXWalletServer>(*httpServer,
......
......@@ -202,7 +202,6 @@ void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign, bool _generate
if (useHTTPS) {
SGXWalletServer::initHttpsServer(_checkCert);
ZMQServer::initZMQServer(_checkCert);
SGXRegistrationServer::initRegistrationServer(_autoSign);
CSRManagerServer::initCSRManagerServer();
ZMQServer::initZMQServer(_checkCert);
......
......@@ -51,7 +51,7 @@ void ZMQServer::run() {
auto port = BASE_PORT + 5;
spdlog::info("Starting zmq server ...");
spdlog::info("Starting zmq server on port {} ...", port);
try {
frontend_.bind("tcp://*:" + to_string(port));
......@@ -138,7 +138,6 @@ void ZMQServer::exitWorkers() {
spdlog::info("Deleting threads ...");
worker_threads.empty();
}
spdlog::info("Deleting workers ...");
spdlog::info("Deleted workers ...");
......@@ -153,10 +152,16 @@ void ZMQServer::exitZMQServer() {
}
void ZMQServer::initZMQServer(bool _useClientCert) {
static bool initedServer = false;
CHECK_STATE(!initedServer)
initedServer = true;
spdlog::info("Initing zmq server ...");
zmqServer = new ZMQServer();
static std::thread serverThread(std::bind(&ZMQServer::run, ZMQServer::zmqServer));
serverThread.detach();
serverThread =make_shared<thread> (std::bind(&ZMQServer::run, ZMQServer::zmqServer));
serverThread->detach();
if (_useClientCert) {
string rootCAPath = string(SGXDATA_FOLDER) + "cert_data/rootCA.pem";
......@@ -164,4 +169,6 @@ void ZMQServer::initZMQServer(bool _useClientCert) {
};
spdlog::info("Inited zmq server ...");
}
\ No newline at end of file
}
shared_ptr<std::thread> ZMQServer::serverThread = nullptr;
\ No newline at end of file
......@@ -46,6 +46,8 @@ public:
static ZMQServer *zmqServer;
static shared_ptr<std::thread> serverThread;
ZMQServer();
enum {
......@@ -74,4 +76,6 @@ private:
};
#endif //SGXWALLET_ZMQServer_H
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