diff --git a/control_plane/src/storage.rs b/control_plane/src/storage.rs index fb498cff15..1fb8d2d474 100644 --- a/control_plane/src/storage.rs +++ b/control_plane/src/storage.rs @@ -44,14 +44,15 @@ impl PageServerNode { pub fn init(&self) -> Result<()> { let mut cmd = Command::new(self.env.pageserver_bin()?); let status = cmd - .args(&["--init", "-D", self.env.base_data_dir.to_str().unwrap()]) + .args(&[ + "--init", + "-D", + self.env.base_data_dir.to_str().unwrap(), + "--postgres-distrib", + self.env.pg_distrib_dir.to_str().unwrap(), + ]) .env_clear() .env("RUST_BACKTRACE", "1") - .env( - "POSTGRES_DISTRIB_DIR", - self.env.pg_distrib_dir.to_str().unwrap(), - ) - .env("ZENITH_REPO_DIR", self.repo_path()) .status() .expect("pageserver init failed"); @@ -83,15 +84,12 @@ impl PageServerNode { self.address().to_string().as_str(), "-D", self.repo_path().to_str().unwrap(), + "--postgres-distrib", + self.env.pg_distrib_dir.to_str().unwrap(), ]) .arg("-d") .env_clear() - .env("RUST_BACKTRACE", "1") - .env( - "POSTGRES_DISTRIB_DIR", - self.env.pg_distrib_dir.to_str().unwrap(), - ) - .env("ZENITH_REPO_DIR", self.repo_path()); + .env("RUST_BACKTRACE", "1"); if !cmd.status()?.success() { bail!( diff --git a/pageserver/src/bin/pageserver.rs b/pageserver/src/bin/pageserver.rs index daa0124979..fa67418c51 100644 --- a/pageserver/src/bin/pageserver.rs +++ b/pageserver/src/bin/pageserver.rs @@ -4,14 +4,15 @@ use log::*; use parse_duration::parse; -use std::io; -use std::process::exit; -use std::thread; -use std::time::Duration; -use std::{env, path::PathBuf}; use std::{ + env, fs::{File, OpenOptions}, + io, net::TcpListener, + path::{Path, PathBuf}, + process::exit, + thread, + time::Duration, }; use anyhow::{Context, Result}; @@ -76,24 +77,20 @@ fn main() -> Result<()> { .takes_value(true) .help("Working directory for the pageserver"), ) + .arg( + Arg::with_name("postgres-distrib") + .long("postgres-distrib") + .takes_value(true) + .help("Postgres distribution directory"), + ) .get_matches(); - let workdir = if let Some(workdir_arg) = arg_matches.value_of("workdir") { - PathBuf::from(workdir_arg) - } else if let Some(workdir_arg) = std::env::var_os("ZENITH_REPO_DIR") { - PathBuf::from(workdir_arg.to_str().unwrap()) - } else { - PathBuf::from(".zenith") - }; + let workdir = Path::new(arg_matches.value_of("workdir").unwrap_or(".zenith")); - let pg_distrib_dir: PathBuf = { - if let Some(postgres_bin) = env::var_os("POSTGRES_DISTRIB_DIR") { - postgres_bin.into() - } else { - let cwd = env::current_dir()?; - cwd.join("tmp_install") - } - }; + let pg_distrib_dir = arg_matches + .value_of("postgres-distrib") + .map(PathBuf::from) + .unwrap_or_else(|| env::current_dir().unwrap().join("tmp_install")); if !pg_distrib_dir.join("bin/postgres").exists() { anyhow::bail!("Can't find postgres binary at {:?}", pg_distrib_dir);