SKALE-4005 check for exit

parent aef2a84f
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "ExitHandler.h"
#include "SGXException.h" #include "SGXException.h"
#include "LevelDB.h" #include "LevelDB.h"
...@@ -172,6 +173,7 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) { ...@@ -172,6 +173,7 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
if (!server->StartListening()) { if (!server->StartListening()) {
spdlog::error("Registration server could not start listening on port {}", BASE_PORT + 1); spdlog::error("Registration server could not start listening on port {}", BASE_PORT + 1);
ExitHandler::exitHandler(SIGTERM, ExitHandler::ec_failure);
exit(-10); exit(-10);
} else { } else {
spdlog::info("Registration server started on port {}", BASE_PORT + 1); spdlog::info("Registration server started on port {}", BASE_PORT + 1);
...@@ -180,6 +182,19 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) { ...@@ -180,6 +182,19 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
return 0; return 0;
} }
int SGXRegistrationServer::exitServer() {
spdlog::info("Stoping registration server");
if (!server->StopListening()) {
spdlog::error("Registration server could not be stopped");
exit(-102);
} else {
spdlog::info("Registration server stopped");
}
return 0;
}
shared_ptr<SGXRegistrationServer> SGXRegistrationServer::getServer() { shared_ptr<SGXRegistrationServer> SGXRegistrationServer::getServer() {
CHECK_STATE(server); CHECK_STATE(server);
......
...@@ -62,7 +62,8 @@ public: ...@@ -62,7 +62,8 @@ public:
static int initRegistrationServer(bool _autoSign = false); static int initRegistrationServer(bool _autoSign = false);
static int exitServer();
}; };
#endif // SGXD_SGXREGISTRATIONSERVER_H #endif // SGXD_SGXREGISTRATIONSERVER_H
\ No newline at end of file
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