From 443b243ba1e9e50e29b11d55903c15916d2a9e52 Mon Sep 17 00:00:00 2001 From: Dennis Silin Date: Tue, 23 Sep 2025 20:30:21 -0400 Subject: [PATCH 1/3] Added a test solution for github issue 430 --- pgdog/src/cli.rs | 20 ++++++++++++++++++-- pgdog/src/main.rs | 29 ++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/pgdog/src/cli.rs b/pgdog/src/cli.rs index 05bbbbbe..858b323c 100644 --- a/pgdog/src/cli.rs +++ b/pgdog/src/cli.rs @@ -56,7 +56,23 @@ pub enum Commands { }, /// Check configuration files for errors. - Configcheck, + Configcheck { + /// Path to the configuration file. + #[arg(short, long)] + config: Option, + /// Path to the users.toml file. + #[arg(short, long)] + users: Option, + }, + + Psql { + /// database to connect to + #[arg(short, long)] + database: Option, + /// user to auth with + #[arg(short, long)] + user: Option, + }, /// Copy data from source to destination cluster /// using logical replication. @@ -302,4 +318,4 @@ pub async fn setup(database: &str) -> Result<(), Box> { ShardConfig::sync_all(&schema_owner).await?; Ok(()) -} +} \ No newline at end of file diff --git a/pgdog/src/main.rs b/pgdog/src/main.rs index d970dd87..c9a16d54 100644 --- a/pgdog/src/main.rs +++ b/pgdog/src/main.rs @@ -11,9 +11,10 @@ use pgdog::stats; use pgdog::util::pgdog_version; use pgdog::{healthcheck, net}; use tokio::runtime::Builder; -use tracing::{error, info}; +use tracing::info; use std::process::exit; +use std::process::Command; #[cfg(not(target_env = "msvc"))] use tikv_jemallocator::Jemalloc; @@ -35,13 +36,31 @@ fn main() -> Result<(), Box> { exit(0); } - Some(Commands::Configcheck) => { - if let Err(e) = config::load(&args.config, &args.users) { - error!("{}", e); + Some(Commands::Psql { + ref database, + ref user, + }) => { + #[cfg(unix)] + { + let _output = Command::new("psql") + .args([ + "--dbname", + &database.clone().expect("Database argument expected"), + "--user", + &user.clone().expect("User argument expected"), + ]) + .spawn()? + .wait(); + } + } + + Some(Commands::Configcheck { config, users }) => { + if let Err(e) = pgdog::cli::config_check(config, users) { + eprintln!("Configuration error: {}", e); exit(1); } - info!("✅ config valid"); + println!("✅ Configuration valid"); exit(0); } From 0d35820df42935413c5cfa492f5f0e33fff8b3b5 Mon Sep 17 00:00:00 2001 From: Dennis Silin Date: Tue, 23 Sep 2025 20:33:31 -0400 Subject: [PATCH 2/3] Adding small fix from cargo fmt --- pgdog/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgdog/src/cli.rs b/pgdog/src/cli.rs index 858b323c..bc0227a8 100644 --- a/pgdog/src/cli.rs +++ b/pgdog/src/cli.rs @@ -318,4 +318,4 @@ pub async fn setup(database: &str) -> Result<(), Box> { ShardConfig::sync_all(&schema_owner).await?; Ok(()) -} \ No newline at end of file +} From d502a026eefb15c79b66720b90864c9fee09f1f9 Mon Sep 17 00:00:00 2001 From: Dennis Silin Date: Tue, 23 Sep 2025 20:36:58 -0400 Subject: [PATCH 3/3] Adding back the main improvements to older code --- pgdog/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pgdog/src/main.rs b/pgdog/src/main.rs index c9a16d54..d7996cf4 100644 --- a/pgdog/src/main.rs +++ b/pgdog/src/main.rs @@ -11,7 +11,7 @@ use pgdog::stats; use pgdog::util::pgdog_version; use pgdog::{healthcheck, net}; use tokio::runtime::Builder; -use tracing::info; +use tracing::{error, info}; use std::process::exit; use std::process::Command; @@ -56,11 +56,11 @@ fn main() -> Result<(), Box> { Some(Commands::Configcheck { config, users }) => { if let Err(e) = pgdog::cli::config_check(config, users) { - eprintln!("Configuration error: {}", e); + error!("Configuration error: {}", e); exit(1); } - println!("✅ Configuration valid"); + info!("✅ Configuration valid"); exit(0); }