another commit
This commit is contained in:
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