From c2b2ab974c9f395d3acdddab3dbe028a2a57c278 Mon Sep 17 00:00:00 2001 From: Stas Kelvich Date: Thu, 20 May 2021 20:58:21 +0300 Subject: [PATCH] Hide initdb output from "zenith init" command --- pageserver/src/branches.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pageserver/src/branches.rs b/pageserver/src/branches.rs index 1dc49d2911..60dca50862 100644 --- a/pageserver/src/branches.rs +++ b/pageserver/src/branches.rs @@ -12,10 +12,10 @@ use postgres_ffi::{pg_constants, xlog_utils}; use rand::Rng; use serde::{Deserialize, Serialize}; use std::env; -use std::io::Read; +use std::io::{Read, Write}; use std::{ collections::HashMap, - fs, + fs, io, path::{Path, PathBuf}, process::{Command, Stdio}, str::FromStr, @@ -65,17 +65,20 @@ pub fn init_repo(conf: &PageServerConf, repo_dir: &Path) -> Result<()> { // and move it to the right location from there. let tmppath = std::path::Path::new("tmp"); + print!("running initdb... "); + io::stdout().flush()?; + let initdb_path = conf.pg_bin_dir().join("initdb"); - let initdb = Command::new(initdb_path) + let initdb_otput = Command::new(initdb_path) .args(&["-D", tmppath.to_str().unwrap()]) .arg("--no-instructions") .env_clear() .env("LD_LIBRARY_PATH", conf.pg_lib_dir().to_str().unwrap()) .env("DYLD_LIBRARY_PATH", conf.pg_lib_dir().to_str().unwrap()) .stdout(Stdio::null()) - .status() + .output() .with_context(|| "failed to execute initdb")?; - if !initdb.success() { + if !initdb_otput.status.success() { anyhow::bail!("initdb failed"); } println!("initdb succeeded");