Imp: config to specify service bind and set default port as 7777
This commit is contained in:
parent
5b1f437773
commit
5c78958ec7
15
src/main.rs
15
src/main.rs
@ -56,10 +56,23 @@ impl AppConfig {
|
|||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Settings {
|
struct Settings {
|
||||||
|
#[serde(default = "Settings::default_bind_localhost")]
|
||||||
|
bind: String,
|
||||||
|
#[serde(default = "Settings::default_port")]
|
||||||
port: u16,
|
port: u16,
|
||||||
apps: HashMap<String, AppConfig>,
|
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)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct QueryParams {
|
struct QueryParams {
|
||||||
auth_token: String,
|
auth_token: String,
|
||||||
@ -342,7 +355,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
APPS_DEPLOYMENT_LOCK.get_or_init(|| RwLock::new(HashSet::new()));
|
APPS_DEPLOYMENT_LOCK.get_or_init(|| RwLock::new(HashSet::new()));
|
||||||
|
|
||||||
HttpServer::new(|| App::new().service(deploy))
|
HttpServer::new(|| App::new().service(deploy))
|
||||||
.bind(("127.0.0.1", settings.port))?
|
.bind((settings.bind.as_str(), settings.port))?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user