make server listen on localhost

This commit is contained in:
Joe Ardent 2024-04-15 20:45:36 -07:00
parent a1379615a0
commit 79da5a02a6

View file

@ -1,8 +1,12 @@
use std::net::SocketAddr; use std::net::SocketAddr;
use clap::Parser;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use what2watch::get_db_pool; use what2watch::get_db_pool;
#[derive(Debug, Parser)]
struct Cli {}
fn main() { fn main() {
tracing_subscriber::registry() tracing_subscriber::registry()
.with( .with(
@ -24,7 +28,7 @@ fn main() {
let app = rt.block_on(what2watch::app(pool.clone())); let app = rt.block_on(what2watch::app(pool.clone()));
rt.block_on(async { rt.block_on(async {
let addr: SocketAddr = ([0, 0, 0, 0], 3000).into(); let addr: SocketAddr = ([127, 0, 0, 1], 3000).into();
tracing::debug!("binding to {addr:?}"); tracing::debug!("binding to {addr:?}");
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app) axum::serve(listener, app)