fix: send Telegram deployment notification asynchronously
TaxBaik CI/CD / build-and-deploy (push) Successful in 48s

- Move deployment completion alert to background Task
- Prevent blocking app startup waiting for Telegram API
- Fixes 'service not responding' errors during health check
- Add error handling for Telegram send failures

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 16:27:07 +09:00
parent 691e4406f3
commit d3b4d59f3c
+18 -1
View File
@@ -231,22 +231,34 @@ try
{ {
Log.Information("애플리케이션 시작: {Environment}", app.Environment.EnvironmentName); Log.Information("애플리케이션 시작: {Environment}", app.Environment.EnvironmentName);
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{
// 배포 완료 알림을 백그라운드에서 비동기 전송 (앱 시작 블록 방지)
_ = Task.Run(async () =>
{
try
{ {
using (var scope = app.Services.CreateScope()) using (var scope = app.Services.CreateScope())
{ {
var telegramService = scope.ServiceProvider.GetRequiredService<ITelegramNotificationService>(); var telegramService = scope.ServiceProvider.GetRequiredService<ITelegramNotificationService>();
// 배포 완료 알림
await telegramService.SendInfoAsync( await telegramService.SendInfoAsync(
"✅ 배포 완료", "✅ 배포 완료",
$"환경: {app.Environment.EnvironmentName}\n상태: 정상 운영 중"); $"환경: {app.Environment.EnvironmentName}\n상태: 정상 운영 중");
} }
} }
catch (Exception ex)
{
Log.Error(ex, "배포 완료 알림 전송 실패");
}
});
}
app.Run(); app.Run();
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Fatal(ex, "애플리케이션 강종"); Log.Fatal(ex, "애플리케이션 강종");
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{
try
{ {
using (var scope = app.Services.CreateScope()) using (var scope = app.Services.CreateScope())
{ {
@@ -256,6 +268,11 @@ catch (Exception ex)
$"환경: {app.Environment.EnvironmentName}\n오류: {ex.Message}"); $"환경: {app.Environment.EnvironmentName}\n오류: {ex.Message}");
} }
} }
catch (Exception telegramEx)
{
Log.Error(telegramEx, "오류 알림 전송 실패");
}
}
throw; throw;
} }
finally finally