fix: send Telegram deployment notification asynchronously
TaxBaik CI/CD / build-and-deploy (push) Successful in 48s
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:
+29
-12
@@ -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<ITelegramNotificationService>();
|
||||
// 배포 완료 알림
|
||||
await telegramService.SendInfoAsync(
|
||||
"✅ 배포 완료",
|
||||
$"환경: {app.Environment.EnvironmentName}\n상태: 정상 운영 중");
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var telegramService = scope.ServiceProvider.GetRequiredService<ITelegramNotificationService>();
|
||||
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<ITelegramNotificationService>();
|
||||
await telegramService.SendErrorAsync(
|
||||
"❌ 서버 오류",
|
||||
$"환경: {app.Environment.EnvironmentName}\n오류: {ex.Message}");
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var telegramService = scope.ServiceProvider.GetRequiredService<ITelegramNotificationService>();
|
||||
await telegramService.SendErrorAsync(
|
||||
"❌ 서버 오류",
|
||||
$"환경: {app.Environment.EnvironmentName}\n오류: {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception telegramEx)
|
||||
{
|
||||
Log.Error(telegramEx, "오류 알림 전송 실패");
|
||||
}
|
||||
}
|
||||
throw;
|
||||
|
||||
Reference in New Issue
Block a user