Update license check

Former-commit-id: 1579a302a09ad0c07ceb4b8293a884ad60eab993
This commit is contained in:
jinhai 2019-05-15 20:22:04 +08:00
parent 65583daaed
commit 9941416b82
4 changed files with 9 additions and 12 deletions

View File

@ -45,14 +45,15 @@ endif ()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -DELPP_THREAD_SAFE")
if (GPU_VERSION STREQUAL "ON")
set(ENABLE_LICENSE "ON")
add_definitions("-DENABLE_LICENSE")
endif ()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fPIC -DELPP_THREAD_SAFE")
endif()
if (GPU_VERSION STREQUAL "ON")
set(ENABLE_LICENSE "ON")
add_definitions("-DENABLE_LICENSE")
endif ()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
set(VECWISE_ENGINE_INCLUDE ${PROJECT_SOURCE_DIR}/include)

View File

@ -74,7 +74,7 @@ LicenseCheck::AlterFile(const std::string &license_file_path,
{
exit(1);
}
printf("---runing---\n");
// printf("---runing---\n");
pt->expires_at(pt->expires_at() + boost::posix_time::hours(1));
pt->async_wait(boost::bind(AlterFile, license_file_path, boost::asio::placeholders::error, pt));
return SERVER_SUCCESS;
@ -83,8 +83,7 @@ LicenseCheck::AlterFile(const std::string &license_file_path,
ServerError
LicenseCheck::StartCountingDown(const std::string &license_file_path) {
if (!LicenseLibrary::IsFileExistent(license_file_path)) return SERVER_LICENSE_FILE_NOT_EXIST;
if (!LicenseLibrary::IsFileExistent(license_file_path)) exit(1);
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::hours(1));
t.async_wait(boost::bind(AlterFile, license_file_path, boost::asio::placeholders::error, &t));

View File

@ -36,7 +36,6 @@ class LicenseCheck {
static ServerError
StartCountingDown(const std::string &license_file_path);
private:
};

View File

@ -160,10 +160,8 @@ Server::Start() {
exit(1);
}
if(server::LicenseCheck::StartCountingDown(license_file_path) != SERVER_SUCCESS) {
SERVER_LOG_ERROR << "License counter start error";
exit(1);
}
std::thread counting_down(&server::LicenseCheck::StartCountingDown, license_file_path);
counting_down.detach();
#endif
// Handle Signal