Fix bootstrap database creation - use BOOTSTRAP_DB_PASSWORD env var
This commit is contained in:
parent
5d5be5546f
commit
dfb18f75e6
2 changed files with 23 additions and 9 deletions
|
|
@ -921,10 +921,12 @@ impl BootstrapManager {
|
|||
|
||||
if component == "tables" {
|
||||
info!("Starting PostgreSQL database...");
|
||||
|
||||
std::env::set_var("BOOTSTRAP_DB_PASSWORD", &db_password);
|
||||
|
||||
match pm.start("tables") {
|
||||
Ok(_) => {
|
||||
info!("PostgreSQL started successfully");
|
||||
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -932,6 +934,8 @@ impl BootstrapManager {
|
|||
}
|
||||
}
|
||||
|
||||
std::env::remove_var("BOOTSTRAP_DB_PASSWORD");
|
||||
|
||||
info!("Running database migrations...");
|
||||
let database_url =
|
||||
format!("postgres://gbuser:{}@localhost:5432/botserver", db_password);
|
||||
|
|
|
|||
|
|
@ -1047,6 +1047,10 @@ Store credentials in Vault:
|
|||
Ok(())
|
||||
}
|
||||
pub fn run_commands(&self, commands: &[String], target: &str, component: &str) -> Result<()> {
|
||||
self.run_commands_with_password(commands, target, component, &String::new())
|
||||
}
|
||||
|
||||
pub fn run_commands_with_password(&self, commands: &[String], target: &str, component: &str, db_password_override: &str) -> Result<()> {
|
||||
let bin_path = if target == "local" {
|
||||
self.base_path.join("bin").join(component)
|
||||
} else {
|
||||
|
|
@ -1069,7 +1073,12 @@ Store credentials in Vault:
|
|||
PathBuf::from("/opt/gbo/logs")
|
||||
};
|
||||
|
||||
let db_password = match get_database_url_sync() {
|
||||
let db_password = if let Ok(env_pwd) = std::env::var("BOOTSTRAP_DB_PASSWORD") {
|
||||
env_pwd
|
||||
} else if !db_password_override.is_empty() {
|
||||
db_password_override.clone()
|
||||
} else {
|
||||
match get_database_url_sync() {
|
||||
Ok(url) => {
|
||||
let (_, password, _, _, _) = parse_database_url(&url);
|
||||
password
|
||||
|
|
@ -1078,6 +1087,7 @@ Store credentials in Vault:
|
|||
trace!("Vault not available for DB_PASSWORD, using empty string");
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for cmd in commands {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue