diff --git a/TaxBaik.Web/Program.cs b/TaxBaik.Web/Program.cs index 7b90ef0..af3f5ad 100644 --- a/TaxBaik.Web/Program.cs +++ b/TaxBaik.Web/Program.cs @@ -232,14 +232,24 @@ try Log.Information("애플리케이션 시작: {Environment}", app.Environment.EnvironmentName); if (!app.Environment.IsDevelopment()) { - using (var scope = app.Services.CreateScope()) + // 배포 완료 알림을 백그라운드에서 비동기 전송 (앱 시작 블록 방지) + _ = Task.Run(async () => { - var telegramService = scope.ServiceProvider.GetRequiredService(); - // 배포 완료 알림 - await telegramService.SendInfoAsync( - "✅ 배포 완료", - $"환경: {app.Environment.EnvironmentName}\n상태: 정상 운영 중"); - } + try + { + using (var scope = app.Services.CreateScope()) + { + var telegramService = scope.ServiceProvider.GetRequiredService(); + await telegramService.SendInfoAsync( + "✅ 배포 완료", + $"환경: {app.Environment.EnvironmentName}\n상태: 정상 운영 중"); + } + } + catch (Exception ex) + { + Log.Error(ex, "배포 완료 알림 전송 실패"); + } + }); } app.Run(); } @@ -248,12 +258,19 @@ catch (Exception ex) Log.Fatal(ex, "애플리케이션 강종"); if (!app.Environment.IsDevelopment()) { - using (var scope = app.Services.CreateScope()) + try { - var telegramService = scope.ServiceProvider.GetRequiredService(); - await telegramService.SendErrorAsync( - "❌ 서버 오류", - $"환경: {app.Environment.EnvironmentName}\n오류: {ex.Message}"); + using (var scope = app.Services.CreateScope()) + { + var telegramService = scope.ServiceProvider.GetRequiredService(); + await telegramService.SendErrorAsync( + "❌ 서버 오류", + $"환경: {app.Environment.EnvironmentName}\n오류: {ex.Message}"); + } + } + catch (Exception telegramEx) + { + Log.Error(telegramEx, "오류 알림 전송 실패"); } } throw;