Imp: config to specify service bind and set default port as 7777

This commit is contained in:
Manish 2025-06-18 22:00:02 +10:00
parent 5b1f437773
commit 5c78958ec7

View File

@ -56,10 +56,23 @@ impl AppConfig {
#[derive(Debug, Deserialize)]
struct Settings {
#[serde(default = "Settings::default_bind_localhost")]
bind: String,
#[serde(default = "Settings::default_port")]
port: u16,
apps: HashMap<String, AppConfig>,
}
impl Settings {
fn default_port() -> u16 {
7777
}
fn default_bind_localhost() -> String {
String::from("127.0.0.1")
}
}
#[derive(Debug, Deserialize)]
struct QueryParams {
auth_token: String,
@ -342,7 +355,7 @@ async fn main() -> std::io::Result<()> {
APPS_DEPLOYMENT_LOCK.get_or_init(|| RwLock::new(HashSet::new()));
HttpServer::new(|| App::new().service(deploy))
.bind(("127.0.0.1", settings.port))?
.bind((settings.bind.as_str(), settings.port))?
.run()
.await
}