Allow specifying the listener binding as CLI arg 1

This commit is contained in:
Olivier 'reivilibre' 2022-04-04 21:04:43 +01:00
parent 1c0b501a21
commit 360a902263
1 changed files with 11 additions and 2 deletions

View File

@ -4,12 +4,14 @@ use axum::http::StatusCode;
use axum::routing::{get, get_service, post}; use axum::routing::{get, get_service, post};
use axum::Router; use axum::Router;
use env_logger::Env; use env_logger::Env;
use log::info;
use quickpeep::config::WebConfig; use quickpeep::config::WebConfig;
use quickpeep::web::icon_retrieval::retrieve_icon; use quickpeep::web::icon_retrieval::retrieve_icon;
use quickpeep::web::searcher::{search_root, search_search}; use quickpeep::web::searcher::{search_root, search_search};
use quickpeep::web::seed_collector::{seed_collection_root, seed_collection_root_post}; use quickpeep::web::seed_collector::{seed_collection_root, seed_collection_root_post};
use quickpeep::web::IndexAccess; use quickpeep::web::IndexAccess;
use sqlx::sqlite::SqlitePoolOptions; use sqlx::sqlite::SqlitePoolOptions;
use std::net::SocketAddr;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use tower_http::services::ServeDir; use tower_http::services::ServeDir;
@ -85,8 +87,15 @@ async fn main() -> anyhow::Result<()> {
), ),
); );
// run it with hyper on localhost:3000 let bind_to: SocketAddr = std::env::args()
axum::Server::bind(&"0.0.0.0:9001".parse().unwrap()) .skip(1)
.next()
.unwrap_or_else(|| String::from("127.0.0.1:9001"))
.parse()?;
info!("Starting QuickPeep Search UI on {:?}", bind_to);
axum::Server::bind(&bind_to)
.serve(app.into_make_service()) .serve(app.into_make_service())
.await .await
.unwrap(); .unwrap();