diff --git a/control_plane/src/background_process.rs b/control_plane/src/background_process.rs index fbd739ac9e..94666f2870 100644 --- a/control_plane/src/background_process.rs +++ b/control_plane/src/background_process.rs @@ -273,7 +273,7 @@ fn fill_remote_storage_secrets_vars(mut cmd: &mut Command) -> &mut Command { fn fill_env_vars_prefixed_neon(mut cmd: &mut Command) -> &mut Command { for (var, val) in std::env::vars() { - if var.starts_with("NEON_") { + if var.starts_with("NEON_PAGESERVER_") { cmd = cmd.env(var, val); } } diff --git a/libs/utils/src/env_config.rs b/libs/utils/src/env.rs similarity index 51% rename from libs/utils/src/env_config.rs rename to libs/utils/src/env.rs index 4bafbe57a0..b3e326bfd0 100644 --- a/libs/utils/src/env_config.rs +++ b/libs/utils/src/env.rs @@ -1,22 +1,6 @@ -use std::{fmt::Display, str::FromStr}; +//! Wrapper around `std::env::var` for parsing environment variables. -pub fn var_or_else(varname: &str, default: D) -> V -where - V: FromStr, - E: Display, - D: FnOnce() -> V, -{ - match std::env::var(varname) { - Ok(s) => s - .parse() - .map_err(|e| format!("failed to parse env var {varname}: {e:#}")) - .unwrap(), - Err(std::env::VarError::NotPresent) => default(), - Err(std::env::VarError::NotUnicode(_)) => { - panic!("env var {varname} is not unicode") - } - } -} +use std::{fmt::Display, str::FromStr}; pub fn var(varname: &str) -> Option where diff --git a/libs/utils/src/lib.rs b/libs/utils/src/lib.rs index 673c48e450..cd5075613e 100644 --- a/libs/utils/src/lib.rs +++ b/libs/utils/src/lib.rs @@ -26,7 +26,6 @@ pub mod auth; // utility functions and helper traits for unified unique id generation/serialization etc. pub mod id; -pub mod env_config; mod hex; pub use hex::Hex; @@ -90,6 +89,8 @@ pub mod yielding_loop; pub mod zstd; +pub mod env; + /// This is a shortcut to embed git sha into binaries and avoid copying the same build script to all packages /// /// we have several cases: diff --git a/pageserver/src/task_mgr.rs b/pageserver/src/task_mgr.rs index f584f02e3c..d91fdf29a3 100644 --- a/pageserver/src/task_mgr.rs +++ b/pageserver/src/task_mgr.rs @@ -49,7 +49,7 @@ use tracing::{debug, error, info, warn}; use once_cell::sync::Lazy; -use utils::env_config; +use utils::env; use utils::id::TimelineId; // @@ -146,7 +146,7 @@ impl FromStr for TokioRuntimeMode { static ONE_RUNTIME: Lazy> = Lazy::new(|| { let thread_name = "pageserver worker"; - let Some(mode) = env_config::var("NEON_PAGESERVER_USE_ONE_RUNTIME") else { + let Some(mode) = env::var("NEON_PAGESERVER_USE_ONE_RUNTIME") else { // If the env var is not set, leave this static as None. // The single_ return None; @@ -199,7 +199,6 @@ macro_rules! pageserver_runtime { pageserver_runtime!(COMPUTE_REQUEST_RUNTIME, "compute request worker"); pageserver_runtime!(MGMT_REQUEST_RUNTIME, "mgmt request worker"); pageserver_runtime!(WALRECEIVER_RUNTIME, "walreceiver worker"); -// if you change the number of worker threads please change the constant below pageserver_runtime!(BACKGROUND_RUNTIME, "background op worker"); #[derive(Debug, Clone, Copy)]