fix(config): wire up LLM_PROXY__CONFIG_PATH env var and fix database path in service
The app never read the LLM_PROXY__CONFIG_PATH env var, so the systemd service couldn't find /etc/llm-proxy/config.toml and fell back to ./data/llm_proxy.db (owned by root, readonly for llmproxy user). - Add LLM_PROXY__CONFIG_PATH support to config loader (checks env var before falling back to ./config.toml) - Add LLM_PROXY__DATABASE__PATH to service env so the DB path always resolves to /var/lib/llm-proxy/llm_proxy.db regardless of config
This commit is contained in:
@@ -264,6 +264,7 @@ WorkingDirectory=$INSTALL_DIR
|
|||||||
EnvironmentFile=$ENV_FILE
|
EnvironmentFile=$ENV_FILE
|
||||||
Environment="RUST_LOG=info"
|
Environment="RUST_LOG=info"
|
||||||
Environment="LLM_PROXY__CONFIG_PATH=$CONFIG_DIR/config.toml"
|
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
|
ExecStart=$INSTALL_DIR/target/release/$APP_NAME
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
|||||||
@@ -139,11 +139,14 @@ impl AppConfig {
|
|||||||
.set_default("providers.ollama.models", Vec::<String>::new())?;
|
.set_default("providers.ollama.models", Vec::<String>::new())?;
|
||||||
|
|
||||||
// Load from config file if exists
|
// Load from config file if exists
|
||||||
let config_path = config_path.unwrap_or_else(|| {
|
// Priority: explicit path arg > LLM_PROXY__CONFIG_PATH env var > ./config.toml
|
||||||
std::env::current_dir()
|
let config_path = config_path
|
||||||
.unwrap_or_else(|_| PathBuf::from("."))
|
.or_else(|| std::env::var("LLM_PROXY__CONFIG_PATH").ok().map(PathBuf::from))
|
||||||
.join("config.toml")
|
.unwrap_or_else(|| {
|
||||||
});
|
std::env::current_dir()
|
||||||
|
.unwrap_or_else(|_| PathBuf::from("."))
|
||||||
|
.join("config.toml")
|
||||||
|
});
|
||||||
if config_path.exists() {
|
if config_path.exists() {
|
||||||
config_builder = config_builder.add_source(File::from(config_path.clone()).format(FileFormat::Toml));
|
config_builder = config_builder.add_source(File::from(config_path.clone()).format(FileFormat::Toml));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user