Skip to content

Commit

Permalink
feat: Add version log
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Sep 21, 2023
1 parent c7959f1 commit bcca7cd
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 3 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.git
**/target/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support to `POST` *inspect state* requests
- Added snapshot validation. The node will now check whether the snapshot's template hash matches the one stored in the blockchain
- Added `cartesi/rollups-node` docker image with all node binaries
- Added versioning logs to all services

### Changed

Expand Down
1 change: 1 addition & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN cargo chef cook --release --recipe-path recipe.json

# Build application
COPY ./offchain/ .
COPY ./.git ../
RUN cargo build --release

#
Expand Down
62 changes: 62 additions & 0 deletions offchain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ awc = "3.1"
axum = "0.6"
backoff = "0.4"
base64 = "0.21"
built = "0.6"
byteorder = "1.4"
clap = "4.3"
diesel = "2.1"
Expand Down Expand Up @@ -91,5 +92,3 @@ urlencoding = "2.1"
users = "0.11"
uuid = "1.4"

[profile.release]
strip = true # Automatically strip symbols from the binary.
1 change: 1 addition & 0 deletions offchain/advance-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::configure(&config.log_config);

info!(?config, "Starting Advance Runner");

advance_runner::run(config).await.map_err(|e| e.into())
}
1 change: 1 addition & 0 deletions offchain/authority-claimer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use authority_claimer::config::Config;
use std::error::Error;
use tracing::info;


#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Getting the configuration.
Expand Down
5 changes: 5 additions & 0 deletions offchain/dispatcher/src/built/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use built;

pub(crate) fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
}
1 change: 1 addition & 0 deletions offchain/dispatcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::configure(&config.dispatcher_config.log_config);

info!(?config, "Starting Dispatcher");

dispatcher::run(config).await.map_err(|e| e.into())
}
1 change: 1 addition & 0 deletions offchain/graphql-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ test-fixtures = { path = "../test-fixtures" }
awc.workspace = true
serial_test.workspace = true
testcontainers.workspace = true

1 change: 1 addition & 0 deletions offchain/graphql-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::configure(&config.log_config);

info!(?config, "Starting GraphQL Server");

graphql_server::run(config).await.map_err(|e| e.into())
}
1 change: 1 addition & 0 deletions offchain/host-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ mockall.workspace = true
rand.workspace = true
serial_test.workspace = true
tracing-test.workspace = true

1 change: 1 addition & 0 deletions offchain/indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ log = { path = "../log" }
rollups-data = { path = "../data" }
rollups-events = { path = "../rollups-events" }

built = { workspace = true, features = ["git2"] }
clap = { workspace = true, features = ["derive", "env"] }
snafu.workspace = true
tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread"] }
Expand Down
1 change: 1 addition & 0 deletions offchain/indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::configure(&config.log_config);

info!(?config, "Starting Indexer");

indexer::run(config).await.map_err(|e| e.into())
}
1 change: 1 addition & 0 deletions offchain/inspect-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ uuid = { workspace = true, features = ["v4"] }
futures.workspace = true
reqwest = { workspace = true, features = ["json"] }
serial_test.workspace = true

5 changes: 5 additions & 0 deletions offchain/log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ license.workspace = true
version.workspace = true

[dependencies]
built.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[build-dependencies]
built = { workspace = true, features = ["git2"] }
6 changes: 6 additions & 0 deletions offchain/log/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use built;

pub(crate) fn main() {
built::write_built_file()
.expect("Failed to acquire build-time information");
}
6 changes: 6 additions & 0 deletions offchain/log/src/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use built;

pub(crate) fn main() {
built::write_built_file()
.expect("Failed to acquire build-time information");
}
20 changes: 20 additions & 0 deletions offchain/log/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use clap::Parser;
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
use tracing::info;

pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

#[derive(Debug, Parser)]
#[command(name = "log_config")]
Expand Down Expand Up @@ -51,4 +56,19 @@ pub fn configure(config: &LogConfig) {
} else {
subscribe_builder.init();
}

log_build_info();
}

pub fn log_build_info() {

info!("Version: {}", built_info::PKG_VERSION);
match built_info::GIT_HEAD_REF {
Some(v) => info!("Git ref: {}", v),
None => (),
}
match built_info::GIT_COMMIT_HASH {
Some(v) => info!("Git hash: {}", v),
None => (),
}
}

0 comments on commit bcca7cd

Please sign in to comment.