another commit
This commit is contained in:
1
.env
1
.env
@@ -3,3 +3,4 @@ INTRASYS_PORT=8080
|
||||
PGUSER=postgres
|
||||
PGHOST=127.0.0.1
|
||||
PGPASSWORD=password
|
||||
INTRASYS_LOG=trace
|
||||
|
@@ -11,7 +11,6 @@ serde_json = "1.0"
|
||||
sqlx = { version = "0.8", features = ["postgres", "runtime-tokio", "chrono", "bigdecimal", "derive"] }
|
||||
thiserror = "2.0"
|
||||
uuid = { version = "1.17", features = ["v4"] }
|
||||
# validator = { version = "0.20", features = ["derive"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
dotenv = "0.15"
|
||||
|
18
src/main.rs
18
src/main.rs
@@ -5,24 +5,26 @@ use axum::{
|
||||
routing::{get, post},
|
||||
};
|
||||
use dotenv::dotenv;
|
||||
use tracing::{Level, info};
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
use tracing::info;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
|
||||
mod db;
|
||||
mod errors;
|
||||
mod handlers;
|
||||
mod models;
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
//Parse .env file and add the environmental variables configured there
|
||||
dotenv().ok();
|
||||
|
||||
let subscriber = FmtSubscriber::builder()
|
||||
.with_max_level(Level::TRACE)
|
||||
.finish();
|
||||
let subscriber = tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(
|
||||
std::env::var("INTRASYS_LOG").unwrap_or_else(|_| "info".into()),
|
||||
))
|
||||
.with(tracing_subscriber::fmt::layer());
|
||||
tracing::subscriber::set_global_default(subscriber)
|
||||
.expect("Setting default tracing subscriber failed");
|
||||
.expect("Failed to set the global tracing subscriber");
|
||||
|
||||
let pool = db::create_pool().await.expect("Failed to create pool");
|
||||
|
||||
@@ -41,7 +43,7 @@ async fn main() {
|
||||
// Run the server
|
||||
let host = env::var("INTRASYS_HOST").unwrap_or(String::from("127.0.0.1"));
|
||||
let port = env::var("INTRASYS_PORT").unwrap_or(String::from("8080"));
|
||||
let listener = tokio::net::TcpListener::bind(format!("{}:{}", host, port))
|
||||
let listener = tokio::net::TcpListener::bind(format!("{host}:{port}"))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("listening on {}", listener.local_addr().unwrap());
|
||||
|
Reference in New Issue
Block a user