fix: Fix compilation errors from path refactoring
Some checks failed
BotServer CI/CD / build (push) Failing after 1m27s
Some checks failed
BotServer CI/CD / build (push) Failing after 1m27s
- bootstrap_utils.rs: Change Vec<(&'static str,...)> to Vec<(String,...)> to avoid dangling references - bootstrap_manager.rs: Use name.as_str() for safe_pkill - setup.rs: Use PathBuf instead of Path::new with format! - directory/bootstrap.rs: Use PathBuf for pat_dir - main.rs: Use PathBuf for vault_init_path_early
This commit is contained in:
parent
7d8f141fc2
commit
552d58376f
5 changed files with 32 additions and 30 deletions
|
|
@ -36,8 +36,7 @@ impl BootstrapManager {
|
||||||
|
|
||||||
let processes = crate::core::bootstrap::bootstrap_utils::get_processes_to_kill();
|
let processes = crate::core::bootstrap::bootstrap_utils::get_processes_to_kill();
|
||||||
for (name, args) in processes {
|
for (name, args) in processes {
|
||||||
// safe_pkill expects &[&str] for pattern, so convert the name
|
safe_pkill(&[name.as_str()], &args);
|
||||||
safe_pkill(&[name], &args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give processes time to terminate
|
// Give processes time to terminate
|
||||||
|
|
|
||||||
|
|
@ -4,32 +4,32 @@ use crate::security::command_guard::SafeCommand;
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
|
|
||||||
/// Get list of processes to kill (only used in dev with local botserver-stack)
|
/// Get list of processes to kill (only used in dev with local botserver-stack)
|
||||||
pub fn get_processes_to_kill() -> Vec<(&'static str, Vec<&'static str>)> {
|
pub fn get_processes_to_kill() -> Vec<(String, Vec<&'static str>)> {
|
||||||
let stack = get_stack_path();
|
let stack = get_stack_path();
|
||||||
vec![
|
vec![
|
||||||
(&format!("{}/bin/vault", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/vault", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/tables", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/tables", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/drive", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/drive", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/cache", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/cache", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/directory", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/directory", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/llm", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/llm", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/email", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/email", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/proxy", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/proxy", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/dns", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/dns", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/meeting", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/meeting", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/vector_db", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/vector_db", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/zitadel", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/zitadel", stack), vec!["-9", "-f"]),
|
||||||
(&format!("{}/bin/alm", stack), vec!["-9", "-f"]),
|
(format!("{}/bin/alm", stack), vec!["-9", "-f"]),
|
||||||
("forgejo", vec!["-9", "-f"]),
|
("forgejo".to_string(), vec!["-9", "-f"]),
|
||||||
("caddy", vec!["-9", "-f"]),
|
("caddy".to_string(), vec!["-9", "-f"]),
|
||||||
("postgres", vec!["-9", "-f"]),
|
("postgres".to_string(), vec!["-9", "-f"]),
|
||||||
("minio", vec!["-9", "-f"]),
|
("minio".to_string(), vec!["-9", "-f"]),
|
||||||
("redis-server", vec!["-9", "-f"]),
|
("redis-server".to_string(), vec!["-9", "-f"]),
|
||||||
("zitadel", vec!["-9", "-f"]),
|
("zitadel".to_string(), vec!["-9", "-f"]),
|
||||||
("llama-server", vec!["-9", "-f"]),
|
("llama-server".to_string(), vec!["-9", "-f"]),
|
||||||
("stalwart", vec!["-9", "-f"]),
|
("stalwart".to_string(), vec!["-9", "-f"]),
|
||||||
("vault server", vec!["-9", "-f"]),
|
("vault server".to_string(), vec!["-9", "-f"]),
|
||||||
("watcher", vec!["-9", "-f"]),
|
("watcher".to_string(), vec!["-9", "-f"]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,8 @@ impl DirectorySetup {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check the legacy location
|
// Also check the legacy location
|
||||||
let legacy_pat_path = std::path::Path::new(&format!("{}/conf/directory/admin-pat.txt", crate::core::shared::utils::get_stack_path()));
|
let stack = crate::core::shared::utils::get_stack_path();
|
||||||
|
let legacy_pat_path = std::path::PathBuf::from(format!("{}/conf/directory/admin-pat.txt", stack));
|
||||||
if legacy_pat_path.exists() {
|
if legacy_pat_path.exists() {
|
||||||
let pat_token = std::fs::read_to_string(legacy_pat_path)
|
let pat_token = std::fs::read_to_string(legacy_pat_path)
|
||||||
.map_err(|e| anyhow::anyhow!("Failed to read PAT file: {e}"))?
|
.map_err(|e| anyhow::anyhow!("Failed to read PAT file: {e}"))?
|
||||||
|
|
|
||||||
|
|
@ -300,8 +300,9 @@ fn save_setup_credentials(result: &BootstrapResult) {
|
||||||
|
|
||||||
fn save_admin_pat_token(pat_token: &str) {
|
fn save_admin_pat_token(pat_token: &str) {
|
||||||
// Create directory if it doesn't exist
|
// Create directory if it doesn't exist
|
||||||
let pat_dir = std::path::Path::new(&format!("{}/conf/directory", get_stack_path()));
|
let stack = get_stack_path();
|
||||||
if let Err(e) = fs::create_dir_all(pat_dir) {
|
let pat_dir = std::path::PathBuf::from(format!("{}/conf/directory", stack));
|
||||||
|
if let Err(e) = fs::create_dir_all(&pat_dir) {
|
||||||
error!("Failed to create PAT directory: {}", e);
|
error!("Failed to create PAT directory: {}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,8 @@ async fn main() -> std::io::Result<()> {
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
|
|
||||||
let env_path_early = std::path::Path::new("./.env");
|
let env_path_early = std::path::Path::new("./.env");
|
||||||
let vault_init_path_early = std::path::Path::new(&format!("{}/conf/vault/init.json", crate::core::shared::utils::get_stack_path()));
|
let stack = crate::core::shared::utils::get_stack_path();
|
||||||
|
let vault_init_path_early = std::path::PathBuf::from(format!("{}/conf/vault/init.json", stack));
|
||||||
let vault_addr = std::env::var("VAULT_ADDR").unwrap_or_default();
|
let vault_addr = std::env::var("VAULT_ADDR").unwrap_or_default();
|
||||||
let is_remote_vault = !vault_addr.is_empty()
|
let is_remote_vault = !vault_addr.is_empty()
|
||||||
&& !vault_addr.contains("localhost")
|
&& !vault_addr.contains("localhost")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue