diff --git a/rust/server/src/main.rs b/rust/server/src/main.rs index 16515c4..2f9b6a2 100644 --- a/rust/server/src/main.rs +++ b/rust/server/src/main.rs @@ -151,7 +151,7 @@ fn main() { }; let rest_svc_listener = TcpListener::bind(&config.bind_address).await.unwrap_or_else(|e| { - error!("Failed to bind listening port: {}", e); + error!("Failed to bind to address {}: {}", config.bind_address, e); std::process::exit(-1); }); info!("Listening for incoming connections on {}{}", config.bind_address, crate::vss_service::BASE_PATH_PREFIX); diff --git a/rust/server/src/util/config.rs b/rust/server/src/util/config.rs index 2252653..6933435 100644 --- a/rust/server/src/util/config.rs +++ b/rust/server/src/util/config.rs @@ -27,7 +27,7 @@ struct TomlConfig { #[derive(Deserialize)] struct ServerConfig { - bind_address: Option, + bind_address: Option, } #[derive(Deserialize)] @@ -39,7 +39,7 @@ struct JwtAuthConfig { struct PostgreSQLConfig { username: Option, password: Option, - address: Option, + address: Option, default_database: Option, vss_database: Option, tls: Option, @@ -58,7 +58,7 @@ struct LogConfig { // Encapsulates the result of reading both the environment variables and the config file. pub(crate) struct Configuration { - pub(crate) bind_address: SocketAddr, + pub(crate) bind_address: String, pub(crate) rsa_pem: Option, pub(crate) postgresql_prefix: String, pub(crate) default_db: String, @@ -99,13 +99,7 @@ pub(crate) fn load_configuration(config_file_path: Option<&str>) -> Result TomlConfig::default(), // All fields are set to `None` }; - let bind_address_env = read_env(BIND_ADDR_VAR)? - .map(|addr| { - addr.parse().map_err(|e| { - format!("Unable to parse the bind address environment variable: {}", e) - }) - }) - .transpose()?; + let bind_address_env = read_env(BIND_ADDR_VAR)?; let bind_address = read_config( bind_address_env, server_config.and_then(|c| c.bind_address), @@ -146,13 +140,7 @@ pub(crate) fn load_configuration(config_file_path: Option<&str>) -> Result = read_env(PSQL_ADDR_VAR)? - .map(|address| { - address.parse().map_err(|e| { - format!("Unable to parse the postgresql address environment variable: {}", e) - }) - }) - .transpose()?; + let address_env: Option = read_env(PSQL_ADDR_VAR)?; let default_db_env = read_env(PSQL_DB_VAR)?; let vss_db_env = read_env(PSQL_VSS_DB_VAR)?; let tls_config_env = read_env(PSQL_TLS_VAR)?;