Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log version and rev on binaries startup #705

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "avail-light-bootstrap"
version = "0.3.0"
build = "../build.rs"
edition = "2021"
description = "Avail network Bootstrap Node for p2p Light Client"

Expand Down
3 changes: 3 additions & 0 deletions bootstrap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ async fn run() -> Result<()> {
warn!("Using default log level: {err}");
}

let version = clap::crate_version!();
let rev = env!("GIT_COMMIT_HASH");
info!(version, rev, "Running {}", clap::crate_name!());
info!("Using config: {:?}", cfg);

let cfg_libp2p: LibP2PConfig = (&cfg).into();
Expand Down
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::process::Command;

fn main() {
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.expect("Failed to get commit hash")
.stdout;

let commit_hash = String::from_utf8(output).expect("Invalid UTF-8 in command output");
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", commit_hash.trim());
}
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "avail-light-client"
version = "1.12.0"
build = "../build.rs"
edition = "2021"
description = "Avail network p2p Light Client"

Expand Down
3 changes: 2 additions & 1 deletion client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ async fn run(
execution_id: Uuid,
) -> Result<()> {
let version = clap::crate_version!();
info!("Running Avail Light Client version: {version}.");
let rev = env!("GIT_COMMIT_HASH");
info!(version, rev, "Running {}", clap::crate_name!());
info!("Using config: {cfg:?}");
info!(
"Avail ss58 address: {}, public key: {}",
Expand Down
1 change: 1 addition & 0 deletions crawler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "avail-light-crawler"
version = "0.1.0"
authors.workspace = true
build = "../build.rs"
edition = "2021"
repository.workspace = true

Expand Down
3 changes: 2 additions & 1 deletion crawler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub async fn main() -> Result<()> {

async fn run(config: Config, db: DB, shutdown: Controller<String>) -> Result<()> {
let version = clap::crate_version!();
info!("Running Avail Light Client Crawler v{version}");
let rev = env!("GIT_COMMIT_HASH");
info!(version, rev, "Running {}", clap::crate_name!());
info!("Using configuration: {config:?}");

let (p2p_keypair, p2p_peer_id) = p2p::identity(&config.libp2p, db.clone())?;
Expand Down
1 change: 1 addition & 0 deletions fat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "avail-light-fat"
version = "1.12.0"
authors.workspace = true
build = "../build.rs"
edition = "2021"
repository.workspace = true

Expand Down
5 changes: 3 additions & 2 deletions fat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ async fn main() -> Result<()> {

async fn run(config: Config, db: DB, shutdown: Controller<String>) -> Result<()> {
let version = clap::crate_version!();
info!("Running Avail Light Fat Client v{version}");
let rev = env!("GIT_COMMIT_HASH");
info!(version, rev, "Running {}", clap::crate_name!());
info!("Using configuration: {config:?}");

let (p2p_keypair, p2p_peer_id) = p2p::identity(&config.libp2p, db.clone())?;
Expand Down Expand Up @@ -177,7 +178,7 @@ async fn run(config: Config, db: DB, shutdown: Controller<String>) -> Result<()>
db: db.clone(),
cfg: SharedConfig::default(),
identity_cfg,
version: format!("v{}", clap::crate_version!()),
version: format!("v{version}"),
network_version: EXPECTED_SYSTEM_VERSION[0].to_string(),
node_client: rpc_client.clone(),
ws_clients: ws_clients.clone(),
Expand Down
1 change: 1 addition & 0 deletions relay/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "avail-light-relay"
version = "0.0.3"
build = "../build.rs"
edition = "2021"
description = "Avail network Relay Node for p2p Light Client"

Expand Down
4 changes: 3 additions & 1 deletion relay/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ async fn run() -> Result<()> {
warn!("Using default log level: {err}");
}

info!("Relay node starting ...");
let version = clap::crate_version!();
let rev = env!("GIT_COMMIT_HASH");
info!(version, rev, "Running {}", clap::crate_name!());

tokio::spawn(server::run((&cfg).into()));

Expand Down
Loading