Skip to content

Commit

Permalink
Allow to select port number as command line argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Oct 20, 2021
1 parent afa3be2 commit bfb0fde
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,15 @@ fn aeon_to_sbml_instantiated(data: Data) -> BackendResponse {
fn main() {
//test_main::run();
let address = std::env::var("AEON_ADDR").unwrap_or_else(|_| "localhost".to_string());
let port: u16 = std::env::var("AEON_PORT")
let port_from_args = {
let mut args = std::env::args();
args.next(); // Skip binary path
args.next().and_then(|s| s.parse::<u16>().ok())
};
let port_from_env = std::env::var("AEON_PORT")
.ok()
.and_then(|s| s.parse::<u16>().ok())
.unwrap_or(8000);
.and_then(|s| s.parse::<u16>().ok());
let port: u16 = port_from_args.or(port_from_env).unwrap_or(8000);
let config = Config::build(Environment::Production)
.address(address)
.port(port)
Expand Down

0 comments on commit bfb0fde

Please sign in to comment.