Add Redis URL logging for debugging connection issues
This commit is contained in:
@@ -23,14 +23,21 @@ impl AppState {
|
||||
/// Инициализация нового состояния приложения.
|
||||
pub async fn new() -> Self {
|
||||
let security_config = SecurityConfig::default();
|
||||
Self::new_with_config(security_config).await
|
||||
Self::new_with_config(security_config).await.unwrap_or_else(|e| {
|
||||
log::error!("❌ Failed to initialize AppState: {}", e);
|
||||
std::process::exit(1);
|
||||
})
|
||||
}
|
||||
|
||||
/// Инициализация с кастомной конфигурацией безопасности.
|
||||
pub async fn new_with_config(security_config: SecurityConfig) -> Self {
|
||||
pub async fn new_with_config(security_config: SecurityConfig) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
// Получаем конфигурацию для Redis с таймаутом
|
||||
let redis_url = env::var("REDIS_URL").expect("REDIS_URL must be set");
|
||||
let redis_client = RedisClient::open(redis_url).expect("Invalid Redis URL");
|
||||
log::info!("🔗 Attempting Redis connection to: {}", redis_url.replace(&redis_url.split('@').nth(0).unwrap_or(""), "***"));
|
||||
let redis_client = RedisClient::open(redis_url.clone()).map_err(|e| {
|
||||
log::error!("❌ Failed to parse Redis URL: {}", e);
|
||||
e
|
||||
})?;
|
||||
|
||||
// Устанавливаем таймаут для Redis операций с graceful fallback
|
||||
let redis_connection = match tokio::time::timeout(
|
||||
@@ -127,7 +134,7 @@ impl AppState {
|
||||
// Кэшируем список файлов из AWS при старте приложения
|
||||
app_state.cache_filelist().await;
|
||||
|
||||
app_state
|
||||
Ok(app_state)
|
||||
}
|
||||
|
||||
/// Кэширует список файлов из Storj S3 в Redis.
|
||||
|
||||
Reference in New Issue
Block a user