Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
115 lines
2.9 KiB
PHP
115 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class ProvisioningQueueItem extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'provisioning_queue';
|
|
|
|
public const STATUS_QUEUED = 'queued';
|
|
public const STATUS_PROCESSING = 'processing';
|
|
public const STATUS_COMPLETED = 'completed';
|
|
public const STATUS_FAILED = 'failed';
|
|
public const STATUS_CANCELLED = 'cancelled';
|
|
|
|
public const PROVIDER_SHARED_NODE = 'shared_node';
|
|
public const PROVIDER_CONTABO_VPS = 'contabo_vps';
|
|
public const PROVIDER_CONTABO_DEDICATED = 'contabo_dedicated';
|
|
|
|
protected $fillable = [
|
|
'customer_hosting_order_id',
|
|
'status',
|
|
'provider',
|
|
'attempts',
|
|
'max_attempts',
|
|
'started_at',
|
|
'completed_at',
|
|
'error_message',
|
|
'provisioning_log',
|
|
];
|
|
|
|
protected $casts = [
|
|
'attempts' => 'integer',
|
|
'max_attempts' => 'integer',
|
|
'started_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'provisioning_log' => 'array',
|
|
];
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CustomerHostingOrder::class, 'customer_hosting_order_id');
|
|
}
|
|
|
|
public function scopeQueued($query)
|
|
{
|
|
return $query->where('status', self::STATUS_QUEUED);
|
|
}
|
|
|
|
public function scopeProcessing($query)
|
|
{
|
|
return $query->where('status', self::STATUS_PROCESSING);
|
|
}
|
|
|
|
public function scopeFailed($query)
|
|
{
|
|
return $query->where('status', self::STATUS_FAILED);
|
|
}
|
|
|
|
public function canRetry(): bool
|
|
{
|
|
return $this->status === self::STATUS_FAILED && $this->attempts < $this->max_attempts;
|
|
}
|
|
|
|
public function markAsProcessing(): void
|
|
{
|
|
$this->update([
|
|
'status' => self::STATUS_PROCESSING,
|
|
'started_at' => now(),
|
|
'attempts' => $this->attempts + 1,
|
|
]);
|
|
}
|
|
|
|
public function markAsCompleted(): void
|
|
{
|
|
$this->update([
|
|
'status' => self::STATUS_COMPLETED,
|
|
'completed_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function markAsFailed(string $error): void
|
|
{
|
|
$log = $this->provisioning_log ?? [];
|
|
$log[] = [
|
|
'timestamp' => now()->toIso8601String(),
|
|
'attempt' => $this->attempts,
|
|
'error' => $error,
|
|
];
|
|
|
|
$this->update([
|
|
'status' => self::STATUS_FAILED,
|
|
'error_message' => $error,
|
|
'provisioning_log' => $log,
|
|
]);
|
|
}
|
|
|
|
public function addLog(string $message, string $level = 'info'): void
|
|
{
|
|
$log = $this->provisioning_log ?? [];
|
|
$log[] = [
|
|
'timestamp' => now()->toIso8601String(),
|
|
'level' => $level,
|
|
'message' => $message,
|
|
];
|
|
|
|
$this->update(['provisioning_log' => $log]);
|
|
}
|
|
}
|