Skip to content

Commit 2665d34

Browse files
committed
git hash and more info on server start
1 parent 805d937 commit 2665d34

4 files changed

Lines changed: 139 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 121 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.0"
44
edition = "2024"
55
authors = ["extrawurst <mail@rusticorn.com>"]
66
license = "MIT OR Apache-2.0"
7+
build = "build.rs"
78

89
[dependencies]
910
anyhow = "1.0"
@@ -43,6 +44,10 @@ mockall = "0.13.1"
4344
testcontainers = "0.25"
4445
testcontainers-modules = { version = "0.13", features = ["postgres"] }
4546

47+
[build-dependencies]
48+
anyhow = "1"
49+
vergen-gitcl = "1.0"
50+
4651
[patch.crates-io]
4752
x402-axum = { git = "https://github.com/extrawurst/x402-rs.git", branch = "add-extension-for-settleresponse" }
4853
x402-rs = { git = "https://github.com/extrawurst/x402-rs.git", branch = "add-extension-for-settleresponse" }

build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use vergen_gitcl::{Emitter, GitclBuilder};
2+
3+
// build.rs main func
4+
fn main() -> anyhow::Result<()> {
5+
let gitcl = GitclBuilder::default().branch(true).sha(true).build()?;
6+
Emitter::default().add_instructions(&gitcl)?.emit()?;
7+
8+
Ok(())
9+
}

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ mod models;
3333
mod schema;
3434
mod signals;
3535

36+
pub const GIT_HASH: &str = env!("VERGEN_GIT_SHA");
37+
3638
#[cfg(not(debug_assertions))]
3739
#[must_use]
3840
pub const fn is_debug() -> bool {
@@ -128,6 +130,8 @@ async fn main() -> anyhow::Result<()> {
128130
.install_default()
129131
.expect("Could not install rustls default crypto provider.");
130132

133+
tracing::info!(git = %GIT_HASH, log = log_level, cors_relaxed, cache_size = args.cache_size, "server starting");
134+
131135
run_migrations(&args.db_url)?;
132136

133137
let dbpool = DbPool::build(&args.db_url, args.db_pool_size).await?;

0 commit comments

Comments
 (0)