feat: redirect pg_isready output to /dev/null
				
					
				
			Fixed bug where restore commands were called inside pg_isready loop. Made CommandBuilder::build public. Redirected stdout for pg_isready calls to /dev/null via Stdio::null().
This commit is contained in:
		@@ -63,7 +63,7 @@ impl CommandBuilder {
 | 
			
		||||
        self
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn build(self) -> Result<Command> {
 | 
			
		||||
    pub fn build(self) -> Result<Command> {
 | 
			
		||||
        debug_println!("-----\n{self}\n-----");
 | 
			
		||||
 | 
			
		||||
        let (first, rest) = self.args.split_first().context("empty args")?;
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ use std::{
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
use super::docker_compose;
 | 
			
		||||
use crate::command_builder::CommandBuilder;
 | 
			
		||||
use crate::{command_builder::CommandBuilder, debug_println};
 | 
			
		||||
 | 
			
		||||
fn get_containers() -> Result<[String; 2]> {
 | 
			
		||||
    // get db container
 | 
			
		||||
@@ -55,18 +55,20 @@ pub fn import(file: &Path) -> Result<()> {
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    for command in commands {
 | 
			
		||||
        println!("waiting until pg_isready");
 | 
			
		||||
        debug_println!("waiting until pg_isready");
 | 
			
		||||
        while !CommandBuilder::docker()
 | 
			
		||||
            .args(&format!(
 | 
			
		||||
                "exec {db_container} pg_isready -h postgresdb -p 5432 -U db",
 | 
			
		||||
            ))
 | 
			
		||||
            .build()?
 | 
			
		||||
            .stdout(Stdio::null())
 | 
			
		||||
            .spawn()?
 | 
			
		||||
            .wait()?
 | 
			
		||||
            .success()
 | 
			
		||||
        {
 | 
			
		||||
            thread::sleep(Duration::from_secs(1));
 | 
			
		||||
            CommandBuilder::docker().args(&command).exec()?;
 | 
			
		||||
        }
 | 
			
		||||
        CommandBuilder::docker().args(&command).exec()?;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    println!("restarting containers");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user