deployment failure status
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Jobs\Services;
|
||||
|
||||
use App\Drivers\Driver;
|
||||
use App\Enums\DeploymentStatus;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Models\Deployment;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
@@ -13,6 +13,8 @@ class DeployService implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected Deployment $deployment;
|
||||
|
||||
public function __construct(
|
||||
public Service $service,
|
||||
public ?string $defaultPassword = null,
|
||||
@@ -24,12 +26,11 @@ class DeployService implements ShouldQueue
|
||||
public function handle(): void
|
||||
{
|
||||
$driver = $this->service->driver($this->defaultPassword);
|
||||
/** @var \App\Models\Deployment $deployment */
|
||||
$deployment = $this->service->deployments()->create([
|
||||
$this->deployment = $this->service->deployments()->create([
|
||||
'status' => DeploymentStatus::PENDING,
|
||||
]);
|
||||
foreach ($driver->deploymentPlan->steps as $index => $plannedStep) {
|
||||
$step = $deployment->steps()->create([
|
||||
$step = $this->deployment->steps()->create([
|
||||
'order' => $index + 1,
|
||||
'status' => DeploymentStatus::PENDING,
|
||||
'script' => $plannedStep->getSafeScript(),
|
||||
@@ -42,4 +43,16 @@ class DeployService implements ShouldQueue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(\Throwable $exception): void
|
||||
{
|
||||
if (isset($this->deployment)) {
|
||||
$this->deployment->update([
|
||||
'status' => DeploymentStatus::FAILED,
|
||||
]);
|
||||
$this->service->update([
|
||||
'status' => ServiceStatus::ERROR,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user