feat(config): refresh environment before establishing DB connection
Reload configuration from environment to ensure latest DATABASE_URL and credentials are used before creating the database connection. This prevents stale config values when environment variables change.
This commit is contained in:
parent
0118fd52e9
commit
44c745ef57
1 changed files with 5 additions and 2 deletions
|
|
@ -131,8 +131,11 @@ async fn main() -> std::io::Result<()> {
|
||||||
log::warn!("Failed to upload templates to MinIO: {}", e);
|
log::warn!("Failed to upload templates to MinIO: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = std::sync::Arc::new(cfg.clone());
|
// Refresh configuration from environment to ensure latest DATABASE_URL and credentials
|
||||||
let db_pool = match diesel::Connection::establish(&cfg.database_url()) {
|
dotenv().ok();
|
||||||
|
let refreshed_cfg = AppConfig::from_env();
|
||||||
|
let config = std::sync::Arc::new(refreshed_cfg.clone());
|
||||||
|
let db_pool = match diesel::Connection::establish(&refreshed_cfg.database_url()) {
|
||||||
Ok(conn) => Arc::new(Mutex::new(conn)),
|
Ok(conn) => Arc::new(Mutex::new(conn)),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to connect to main database: {}", e);
|
log::error!("Failed to connect to main database: {}", e);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue