diff --git a/CMakeLists.txt b/CMakeLists.txt index f66ec4b61..06a3b116c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ find_package(MySQL) find_package(Pandoc) find_package(TCMalloc) find_package(Jemalloc) +find_package(Git) find_package(CURL) # You can find the variables set by this in the FindCURL.cmake file # which is a default module in CMake. @@ -56,6 +57,18 @@ else() endif() endif() +if(GIT_FOUND) + message(STATUS "Found git ${GIT_VERSION_STRING}") + execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --max-count=1 HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT) + string(REPLACE "\n" "" MAXSCALE_COMMIT ${GIT_COMMIT}) + message(STATUS "Commit ID: ${MAXSCALE_COMMIT}") +else() + message(WARNING "Could not find git, MaxScale commit ID will not be resolved. Will use 'source-build' for commit ID.") + set(MAXSCALE_COMMIT "source-build") +endif() + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBDIR}) # Make sure the release notes for this release are present if it is a stable one diff --git a/server/core/gateway.c b/server/core/gateway.c index 2eceea4b2..eef1ae643 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -388,12 +388,16 @@ sigfatal_handler (int i) _exit(1); } fatal_handling = 1; - - fprintf(stderr, "\n\nMaxScale received fatal signal %d\n", i); + GATEWAY_CONF* cnf = config_get_global_options(); + fprintf(stderr, "\n\nMaxScale "MAXSCALE_VERSION" received fatal signal %d\n", i); LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, - "Fatal: MaxScale received fatal signal %d. Attempting backtrace.", i))); + "Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i))); + + skygw_log_write_flush(LE,"Commit ID: "MAXSCALE_COMMIT" System name: %s " + "Release string: %s Embedded library version: %s", + cnf->sysname,cnf->release_string,cnf->version_string); { void *addrs[128]; @@ -1148,7 +1152,7 @@ int main(int argc, char **argv) case 'v': rc = EXIT_SUCCESS; - printf("%s\n",MAXSCALE_VERSION); + printf("MaxScale %s\n",MAXSCALE_VERSION); goto return_main; case 'l': diff --git a/server/include/version.h.in b/server/include/version.h.in index 5aced69a5..c15fa862d 100644 --- a/server/include/version.h.in +++ b/server/include/version.h.in @@ -1 +1,2 @@ #define MAXSCALE_VERSION "@MAXSCALE_VERSION@" +#define MAXSCALE_COMMIT "@MAXSCALE_COMMIT@"