From 69feab3bcc3d3903e19e2cb32b6fe54623f21971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 21 Sep 2017 12:36:18 +0100 Subject: [PATCH] allow polaris to run on a custom defined port --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3ba004e..30dc328 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,6 +104,7 @@ fn run() -> Result<()> { let args: Vec = std::env::args().collect(); let mut options = Options::new(); options.optopt("c", "config", "set the configuration file", "FILE"); + options.optopt("p", "port", "set polaris to run on a custom port", "PORT"); options.optopt("d", "database", "set the path to index database", "FILE"); options.optopt("w", "web", "set the path to web client files", "DIRECTORY"); @@ -177,7 +178,8 @@ fn run() -> Result<()> { mount.mount("/", Static::new(web_dir_path)); println!("Starting up server"); - let mut server = match Iron::new(mount).http(("0.0.0.0", 5050)) { + let port: u16 = matches.opt_str("p").unwrap_or("5050".to_owned()).parse().or(Err("invalid port number"))?; + let mut server = match Iron::new(mount).http(("0.0.0.0", port)) { Ok(s) => s, Err(e) => bail!("Error starting up server: {}", e), };