diff --git a/deploy.sh b/deploy.sh index 9d71ac3d..5b4888a9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -264,6 +264,7 @@ WorkingDirectory=$INSTALL_DIR EnvironmentFile=$ENV_FILE Environment="RUST_LOG=info" Environment="LLM_PROXY__CONFIG_PATH=$CONFIG_DIR/config.toml" +Environment="LLM_PROXY__DATABASE__PATH=$DATA_DIR/llm_proxy.db" ExecStart=$INSTALL_DIR/target/release/$APP_NAME Restart=on-failure RestartSec=5 diff --git a/src/config/mod.rs b/src/config/mod.rs index 44e0151e..3f3b4078 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -139,11 +139,14 @@ impl AppConfig { .set_default("providers.ollama.models", Vec::::new())?; // Load from config file if exists - let config_path = config_path.unwrap_or_else(|| { - std::env::current_dir() - .unwrap_or_else(|_| PathBuf::from(".")) - .join("config.toml") - }); + // Priority: explicit path arg > LLM_PROXY__CONFIG_PATH env var > ./config.toml + let config_path = config_path + .or_else(|| std::env::var("LLM_PROXY__CONFIG_PATH").ok().map(PathBuf::from)) + .unwrap_or_else(|| { + std::env::current_dir() + .unwrap_or_else(|_| PathBuf::from(".")) + .join("config.toml") + }); if config_path.exists() { config_builder = config_builder.add_source(File::from(config_path.clone()).format(FileFormat::Toml)); }