VPS and dedicated server ordering, managed panels, SSO, billing, and launcher integration — forked from hosting infrastructure with server-focused routes and dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\ContaboInfrastructureProvision;
|
|
use App\Services\Infrastructure\ContaboInfrastructureProvisioner;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Queue\Queueable;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ProvisionContaboInfrastructureJob implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public int $tries = 30;
|
|
|
|
public int $backoff = 60;
|
|
|
|
public function __construct(
|
|
public ContaboInfrastructureProvision $provision,
|
|
) {}
|
|
|
|
public function handle(ContaboInfrastructureProvisioner $provisioner): void
|
|
{
|
|
$provision = $this->provision->fresh();
|
|
|
|
if (! $provision) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if ($provision->status === ContaboInfrastructureProvision::STATUS_PENDING) {
|
|
$provisioner->createContaboInstance($provision);
|
|
|
|
return;
|
|
}
|
|
|
|
if ($provision->status === ContaboInfrastructureProvision::STATUS_WAITING_IP) {
|
|
if (! $provisioner->pollInstanceIp($provision)) {
|
|
self::dispatch($provision)->delay(now()->addSeconds(30));
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if ($provision->status === ContaboInfrastructureProvision::STATUS_BOOTSTRAPPING) {
|
|
self::dispatch($provision)->delay(now()->addMinutes(2));
|
|
}
|
|
} catch (\Throwable $e) {
|
|
Log::error('Contabo infrastructure provision failed', [
|
|
'provision_id' => $provision->id,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
$provision->markFailed($e->getMessage());
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|