diff --git a/src/bin/tikv-importer.rs b/src/bin/tikv-importer.rs index f1ce03c..34f4cca 100644 --- a/src/bin/tikv-importer.rs +++ b/src/bin/tikv-importer.rs @@ -15,18 +15,42 @@ use tikv::binutil::signal_handler; use clap::{crate_authors, crate_version, App, Arg, ArgMatches}; -#[cfg(unix)] -use tikv::binutil as util; use tikv::fatal; use tikv_importer::import::{ImportKVServer, TiKvConfig}; use tikv_util::{self as tikv_util, check_environment_variables, logger}; +/// Returns the importer version information. +fn importer_version_info() -> String { + let fallback = "Unknown (env var does not exist when building)"; + format!( + "\nRelease Version: {}\ + \nGit Commit Hash: {}\ + \nGit Commit Branch: {}\ + \nUTC Build Time: {}\ + \nRust Version: {}", + env!("CARGO_PKG_VERSION"), + option_env!("TIKV_BUILD_GIT_HASH").unwrap_or(fallback), + option_env!("TIKV_BUILD_GIT_BRANCH").unwrap_or(fallback), + option_env!("TIKV_BUILD_TIME").unwrap_or(fallback), + option_env!("TIKV_BUILD_RUSTC_VERSION").unwrap_or(fallback), + ) +} + +/// Prints the tikv version information to the standard output. +fn log_importer_info() { + info!("Welcome to TiKV Importer."); + for line in importer_version_info().lines() { + info!("{}", line); + } + info!(""); +} + fn main() { let matches = App::new("TiKV Importer") .about("The importer server for TiKV") .author(crate_authors!()) .version(crate_version!()) - .long_version(util::tikv_version_info().as_ref()) + .long_version(&*importer_version_info()) .arg( Arg::with_name("config") .short("C") @@ -79,7 +103,7 @@ fn main() { tikv_util::set_panic_hook(false, &config.storage.data_dir); initial_metric(&config.metric, None); - util::log_tikv_info(); + log_importer_info(); check_environment_variables(); if tikv_util::panic_mark_file_exists(&config.storage.data_dir) {