Skip to content

Commit

Permalink
added tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Jan 29, 2024
1 parent 6837315 commit 37cf9c9
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
66 changes: 66 additions & 0 deletions engine/Cargo.lock

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

2 changes: 2 additions & 0 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ members = ["crates/*"]
tokio = { version = "1.35.1", features = ["full"] }
color-eyre = "0.6.2"
axum = "0.7.4"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
2 changes: 2 additions & 0 deletions engine/crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ edition = "2021"
tokio.workspace = true
color-eyre.workspace = true
axum.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
10 changes: 9 additions & 1 deletion engine/crates/engine/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
use axum::{routing::get, Router};
use color_eyre::eyre::Result;
use tracing::info;

#[tokio::main]
async fn main() -> Result<()> {
color_eyre::install()?;
let subscriber = tracing_subscriber::fmt().finish();
tracing::subscriber::set_global_default(subscriber)?;

let app = Router::new().route("/", get(|| async { "Hello, World!" }));

// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
let port = std::env::var("PORT").unwrap_or_else(|_| "3000".to_string());
let host = std::env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string());
let address = format!("{}:{}", host, port);
let listener = tokio::net::TcpListener::bind(&address).await?;

info!("Listening on {}", address);
axum::serve(listener, app).await?;

Ok(())
Expand Down

0 comments on commit 37cf9c9

Please sign in to comment.