Skip to content

Commit

Permalink
bin: inlines binutil::* so that CARGO_PKG_VERSION is the correct vers…
Browse files Browse the repository at this point in the history
…ion (#14)

Signed-off-by: kennytm <kennytm@gmail.com>
  • Loading branch information
kennytm authored Aug 6, 2019
1 parent 599f61d commit 5f555bf
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/bin/tikv-importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5f555bf

Please sign in to comment.