update assign ip windows

This commit is contained in:
Pham Bao
2025-07-29 23:49:33 +07:00
parent 21a2dfe855
commit 5d6e2060a8
4 changed files with 132 additions and 28 deletions
@@ -163,11 +163,18 @@ class ProcessOrderPaymentJob implements ShouldQueue
// Thử lại nếu chưa vượt quá số lần thử
if ($this->retryCount < self::MAX_RETRIES) {
Log::warning("Có lỗi khi tạo VM, thử lại lần " . ($this->retryCount + 1), $errorDetails);
// Kiểm tra nếu lỗi là timeout, tăng delay time
$isTimeoutError = $this->isTimeoutError($failedVMs);
$delayMinutes = $isTimeoutError ? 10 : 5; // Timeout thì chờ 10 phút, lỗi khác chờ 5 phút
Log::warning("Có lỗi khi tạo VM, thử lại lần " . ($this->retryCount + 1), array_merge($errorDetails, [
'is_timeout_error' => $isTimeoutError,
'delay_minutes' => $delayMinutes
]));
// Thử lại sau 5 phút
// Thử lại với delay tùy theo loại lỗi
self::dispatch($this->order, $this->retryCount + 1)
->delay(now()->addMinutes(5));
->delay(now()->addMinutes($delayMinutes));
} else {
// Đã thử hết số lần, gửi thông báo lỗi
Log::error("Đã thử tạo VM {$this->retryCount} lần nhưng vẫn thất bại", $errorDetails);
@@ -183,9 +190,14 @@ class ProcessOrderPaymentJob implements ShouldQueue
}
} catch (\Throwable $e) {
$isTimeoutException = strpos(strtolower($e->getMessage()), 'timeout') !== false ||
strpos(strtolower($e->getMessage()), 'curl error 28') !== false;
Log::error("Lỗi trong ProcessOrderPaymentJob: " . $e->getMessage(), [
'order_id' => $this->order->id,
'order_num' => $this->order->order_num,
'is_timeout' => $isTimeoutException,
'retry_count' => $this->retryCount,
'trace' => $e->getTraceAsString()
]);
@@ -194,7 +206,9 @@ class ProcessOrderPaymentJob implements ShouldQueue
'order_id' => $this->order->id,
'order_num' => $this->order->order_num,
'file' => $e->getFile(),
'line' => $e->getLine()
'line' => $e->getLine(),
'is_timeout' => $isTimeoutException,
'retry_count' => $this->retryCount
], 'ProcessOrderPaymentJob - Exception');
}
}
@@ -243,6 +257,27 @@ class ProcessOrderPaymentJob implements ShouldQueue
}
}
/**
* Check if the error is a timeout error
*/
private function isTimeoutError(array $failedVMs): bool
{
foreach ($failedVMs as $vmResult) {
if (isset($vmResult['error'])) {
$errorMessage = strtolower($vmResult['error']);
// Kiểm tra các dấu hiệu của timeout error
if (strpos($errorMessage, 'timeout') !== false ||
strpos($errorMessage, 'curl error 28') !== false ||
strpos($errorMessage, 'operation timed out') !== false ||
strpos($errorMessage, 'connection timeout') !== false) {
return true;
}
}
}
return false;
}
/**
* Send failure notification to customer
*/