diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aeede993c7121d754148d471e8c40c83d57c89d..26ae7d351098be7a4584a858f745ec85d2521dec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ if(NOT NEBULA_COMMON_SOURCE_DIR) set(nebula_common_source_dir ${CMAKE_SOURCE_DIR}/modules/common) set(nebula_common_build_dir ${CMAKE_BINARY_DIR}/modules/common) else() + message(STATUS "NEBULA_COMMON_SOURCE_DIR: " ${NEBULA_COMMON_SOURCE_DIR}) set(nebula_common_source_dir ${NEBULA_COMMON_SOURCE_DIR}) if(NOT NEBULA_COMMON_BUILD_DIR) set(nebula_common_build_dir ${CMAKE_BINARY_DIR}/modules/common) @@ -117,6 +118,7 @@ if(ENABLE_BUILD_STORAGE) set(nebula_storage_source_dir ${CMAKE_SOURCE_DIR}/modules/storage) set(nebula_storage_build_dir ${CMAKE_BINARY_DIR}/modules/storage) else() + message(STATUS "NEBULA_STORAGE_SOURCE_DIR: " ${NEBULA_STORAGE_SOURCE_DIR}) set(nebula_storage_source_dir ${NEBULA_STORAGE_SOURCE_DIR}) if(NOT NEBULA_STORAGE_BUILD_DIR) set(nebula_storage_build_dir ${CMAKE_BINARY_DIR}/modules/storage) diff --git a/cmake/ConfigNebulaStorage.cmake b/cmake/ConfigNebulaStorage.cmake index a03e62ae1a4c157e1c93c14ed9462573b2d14c4a..fdea577694efaee2e516cfe0825ead7c442dca7a 100644 --- a/cmake/ConfigNebulaStorage.cmake +++ b/cmake/ConfigNebulaStorage.cmake @@ -19,6 +19,11 @@ macro(config_nebula_storage) file(MAKE_DIRECTORY ${storage_build_dir}) endif() + if (NEBULA_BUILD_VERSION) + message(STATUS "NEBULA_BUILD_VERSION: " ${NEBULA_BUILD_VERSION}) + set(storage_build_version -DNEBULA_BUILD_VERSION=${NEBULA_BUILD_VERSION}) + endif() + execute_process( COMMAND ${CMAKE_COMMAND} @@ -40,6 +45,7 @@ macro(config_nebula_storage) -DENABLE_COMPRESSED_DEBUG_INFO=${ENABLE_COMPRESSED_DEBUG_INFO} -DNEBULA_USE_LINKER=${NEBULA_USE_LINKER} -DENABLE_GDB_SCRIPT_SECTION=${ENABLE_GDB_SCRIPT_SECTION} + ${storage_build_version} ${storage_source_dir} WORKING_DIRECTORY ${storage_build_dir} RESULT_VARIABLE cmake_status diff --git a/conf/nebula-graphd.conf.default b/conf/nebula-graphd.conf.default index c8e412fc09e4067261b93f7cb4882f729c251aca..9b2cfebd15469d6827e6d2a1b89a7497dd9bc246 100644 --- a/conf/nebula-graphd.conf.default +++ b/conf/nebula-graphd.conf.default @@ -18,8 +18,8 @@ # Whether to redirect stdout and stderr to separate output files --redirect_stdout=true # Destination filename of stdout and stderr, which will also reside in log_dir. ---stdout_log_file=stdout.log ---stderr_log_file=stderr.log +--stdout_log_file=graphd-stdout.log +--stderr_log_file=graphd-stderr.log # Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively. --stderrthreshold=2 diff --git a/conf/nebula-graphd.conf.production b/conf/nebula-graphd.conf.production index 107b19c96bda78ed13f0c2fcc0756bc80797eb8e..4e00e9849a20ac06bea691f8d9984c2831f15c5c 100644 --- a/conf/nebula-graphd.conf.production +++ b/conf/nebula-graphd.conf.production @@ -18,8 +18,8 @@ # Whether to redirect stdout and stderr to separate output files --redirect_stdout=true # Destination filename of stdout and stderr, which will also reside in log_dir. ---stdout_log_file=stdout.log ---stderr_log_file=stderr.log +--stdout_log_file=graphd-stdout.log +--stderr_log_file=graphd-stderr.log # Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively. --stderrthreshold=2 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d364bce9a643d2eb5585790c08a20b47e269282c..b87cd1580f25053e5d7f5811b05580f048ec3e25 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,3 +14,4 @@ nebula_add_subdirectory(context) nebula_add_subdirectory(scheduler) nebula_add_subdirectory(visitor) nebula_add_subdirectory(optimizer) +nebula_add_subdirectory(version) diff --git a/src/daemons/CMakeLists.txt b/src/daemons/CMakeLists.txt index 446729f52dd498429d3fca4efd5b65b4df4f8581..201505bcdd5db42bbfda36e0196b7a244a8b3564 100644 --- a/src/daemons/CMakeLists.txt +++ b/src/daemons/CMakeLists.txt @@ -9,6 +9,7 @@ nebula_add_executable( SOURCES GraphDaemon.cpp OBJECTS + $<TARGET_OBJECTS:version_obj> $<TARGET_OBJECTS:util_obj> $<TARGET_OBJECTS:service_obj> $<TARGET_OBJECTS:session_obj> diff --git a/src/daemons/GraphDaemon.cpp b/src/daemons/GraphDaemon.cpp index 63daa44fb8e6b6eedc8baceebd44bec0ea64a4e4..73536cf3cd523b3f8f4ae1a7b3c66e5ce67cb9e2 100644 --- a/src/daemons/GraphDaemon.cpp +++ b/src/daemons/GraphDaemon.cpp @@ -18,6 +18,7 @@ #include "service/GraphFlags.h" #include "common/webservice/WebService.h" #include "common/time/TimeUtils.h" +#include "version/Version.h" using nebula::Status; using nebula::ProcessUtils; @@ -34,7 +35,7 @@ static void printHelp(const char *prog); DECLARE_string(flagfile); int main(int argc, char *argv[]) { - google::SetVersionString(nebula::versionString()); + google::SetVersionString(nebula::graph::versionString()); if (argc == 1) { printHelp(argv[0]); return EXIT_FAILURE; diff --git a/src/planner/test/CMakeLists.txt b/src/planner/test/CMakeLists.txt index 89f08e33948554b31554457049c72e89bc5156c6..c7ea0322d53496d3d63678b88257654e01b20d7c 100644 --- a/src/planner/test/CMakeLists.txt +++ b/src/planner/test/CMakeLists.txt @@ -35,6 +35,7 @@ nebula_add_test( $<TARGET_OBJECTS:common_conf_obj> $<TARGET_OBJECTS:common_file_based_cluster_id_man_obj> $<TARGET_OBJECTS:common_charset_obj> + $<TARGET_OBJECTS:version_obj> $<TARGET_OBJECTS:query_engine_obj> $<TARGET_OBJECTS:session_obj> $<TARGET_OBJECTS:graph_flags_obj> diff --git a/src/service/QueryEngine.cpp b/src/service/QueryEngine.cpp index 5cd34d11f508947bb41a457f3be325f40271fd29..a033fcde3635f6f19decfcba38d813022c26c38e 100644 --- a/src/service/QueryEngine.cpp +++ b/src/service/QueryEngine.cpp @@ -14,6 +14,7 @@ #include "planner/PlannersRegister.h" #include "service/QueryInstance.h" #include "service/GraphFlags.h" +#include "version/Version.h" DECLARE_bool(local_config); DECLARE_bool(enable_optimizer); @@ -34,7 +35,7 @@ Status QueryEngine::init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor options.role_ = meta::cpp2::HostRole::GRAPH; std::string localIP = network::NetworkUtils::getIPv4FromDevice(FLAGS_listen_netdev).value(); options.localHost_ = HostAddr{localIP, FLAGS_port}; - options.gitInfoSHA_ = NEBULA_STRINGIFY(GIT_INFO_SHA); + options.gitInfoSHA_ = nebula::graph::gitInfoSha(); metaClient_ = std::make_unique<meta::MetaClient>(ioExecutor, std::move(addrs.value()), options); // load data try 3 time diff --git a/src/version/CMakeLists.txt b/src/version/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..175cf4e432fa90362fb6a36ac4ae22f92f14ad03 --- /dev/null +++ b/src/version/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2020 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp.in + ${CMAKE_CURRENT_BINARY_DIR}/Version.cpp + ) + +nebula_add_library( + version_obj + OBJECT + ${CMAKE_CURRENT_BINARY_DIR}/Version.cpp + ) diff --git a/src/version/Version.cpp.in b/src/version/Version.cpp.in new file mode 100644 index 0000000000000000000000000000000000000000..e24f65d1763b8d394721e9ce765e6b0a2fd683e0 --- /dev/null +++ b/src/version/Version.cpp.in @@ -0,0 +1,33 @@ +/* Copyright (c) 2020 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License, + * attached with Common Clause Condition 1.0, found in the LICENSES directory. + */ + +#include "version/Version.h" + +#include <folly/String.h> + +#cmakedefine NEBULA_BUILD_VERSION + +namespace nebula { +namespace graph { + +std::string gitInfoSha() { + return "@GIT_INFO_SHA@"; +} + +std::string versionString() { + std::string version; +#if defined(NEBULA_BUILD_VERSION) + version = folly::stringPrintf("%s, ", "@NEBULA_BUILD_VERSION@"); +#endif + version += folly::stringPrintf("Git: %s", gitInfoSha().c_str()); + version += folly::stringPrintf(", Build Time: %s %s", __DATE__, __TIME__); + version += "\nThis source code is licensed under Apache 2.0 License," + " attached with Common Clause Condition 1.0."; + return version; +} + +} // namespace graph +} // namespace nebula diff --git a/src/version/Version.h b/src/version/Version.h new file mode 100644 index 0000000000000000000000000000000000000000..be40f8702f53c582d521914b40090ea5d229efe3 --- /dev/null +++ b/src/version/Version.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2020 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License, + * attached with Common Clause Condition 1.0, found in the LICENSES directory. + */ + +#ifndef VERSION_VERSION_H_ +#define VERSION_VERSION_H_ + +#include <string> + +namespace nebula { +namespace graph { + +std::string gitInfoSha(); +std::string versionString(); + +} // namespace graph +} // namespace nebula + +#endif // VERSION_VERSION_H_