fix: Fix compilation errors from path refactoring
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:
Rodrigo Rodriguez (Pragmatismo) 2026-04-04 10:04:00 -03:00
parent 7d8f141fc2
commit 552d58376f
5 changed files with 32 additions and 30 deletions

View file

@ -36,8 +36,7 @@ impl BootstrapManager {
let processes = crate::core::bootstrap::bootstrap_utils::get_processes_to_kill();
for (name, args) in processes {
// safe_pkill expects &[&str] for pattern, so convert the name
safe_pkill(&[name], &args);
safe_pkill(&[name.as_str()], &args);
}
// Give processes time to terminate

View file

@ -4,32 +4,32 @@ use crate::security::command_guard::SafeCommand;
use log::{debug, info, warn};
/// 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();
vec![
(&format!("{}/bin/vault", stack), vec!["-9", "-f"]),
(&format!("{}/bin/tables", stack), vec!["-9", "-f"]),
(&format!("{}/bin/drive", stack), vec!["-9", "-f"]),
(&format!("{}/bin/cache", stack), vec!["-9", "-f"]),
(&format!("{}/bin/directory", stack), vec!["-9", "-f"]),
(&format!("{}/bin/llm", stack), vec!["-9", "-f"]),
(&format!("{}/bin/email", stack), vec!["-9", "-f"]),
(&format!("{}/bin/proxy", stack), vec!["-9", "-f"]),
(&format!("{}/bin/dns", stack), vec!["-9", "-f"]),
(&format!("{}/bin/meeting", stack), vec!["-9", "-f"]),
(&format!("{}/bin/vector_db", stack), vec!["-9", "-f"]),
(&format!("{}/bin/zitadel", stack), vec!["-9", "-f"]),
(&format!("{}/bin/alm", stack), vec!["-9", "-f"]),
("forgejo", vec!["-9", "-f"]),
("caddy", vec!["-9", "-f"]),
("postgres", vec!["-9", "-f"]),
("minio", vec!["-9", "-f"]),
("redis-server", vec!["-9", "-f"]),
("zitadel", vec!["-9", "-f"]),
("llama-server", vec!["-9", "-f"]),
("stalwart", vec!["-9", "-f"]),
("vault server", vec!["-9", "-f"]),
("watcher", vec!["-9", "-f"]),
(format!("{}/bin/vault", stack), vec!["-9", "-f"]),
(format!("{}/bin/tables", stack), vec!["-9", "-f"]),
(format!("{}/bin/drive", stack), vec!["-9", "-f"]),
(format!("{}/bin/cache", stack), vec!["-9", "-f"]),
(format!("{}/bin/directory", stack), vec!["-9", "-f"]),
(format!("{}/bin/llm", stack), vec!["-9", "-f"]),
(format!("{}/bin/email", stack), vec!["-9", "-f"]),
(format!("{}/bin/proxy", stack), vec!["-9", "-f"]),
(format!("{}/bin/dns", stack), vec!["-9", "-f"]),
(format!("{}/bin/meeting", stack), vec!["-9", "-f"]),
(format!("{}/bin/vector_db", stack), vec!["-9", "-f"]),
(format!("{}/bin/zitadel", stack), vec!["-9", "-f"]),
(format!("{}/bin/alm", stack), vec!["-9", "-f"]),
("forgejo".to_string(), vec!["-9", "-f"]),
("caddy".to_string(), vec!["-9", "-f"]),
("postgres".to_string(), vec!["-9", "-f"]),
("minio".to_string(), vec!["-9", "-f"]),
("redis-server".to_string(), vec!["-9", "-f"]),
("zitadel".to_string(), vec!["-9", "-f"]),
("llama-server".to_string(), vec!["-9", "-f"]),
("stalwart".to_string(), vec!["-9", "-f"]),
("vault server".to_string(), vec!["-9", "-f"]),
("watcher".to_string(), vec!["-9", "-f"]),
]
}

View file

@ -138,7 +138,8 @@ impl DirectorySetup {
}
// 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() {
let pat_token = std::fs::read_to_string(legacy_pat_path)
.map_err(|e| anyhow::anyhow!("Failed to read PAT file: {e}"))?

View file

@ -300,8 +300,9 @@ fn save_setup_credentials(result: &BootstrapResult) {
fn save_admin_pat_token(pat_token: &str) {
// Create directory if it doesn't exist
let pat_dir = std::path::Path::new(&format!("{}/conf/directory", get_stack_path()));
if let Err(e) = fs::create_dir_all(pat_dir) {
let stack = get_stack_path();
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);
return;
}

View file

@ -206,7 +206,8 @@ async fn main() -> std::io::Result<()> {
dotenvy::dotenv().ok();
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 is_remote_vault = !vault_addr.is_empty()
&& !vault_addr.contains("localhost")