failure handling on steps, setting service status
This commit is contained in:
@@ -7,5 +7,6 @@ enum DeploymentStatus: string
|
||||
case PENDING = 'pending';
|
||||
case IN_PROGRESS = 'in-progress';
|
||||
case COMPLETED = 'completed';
|
||||
case CANCELLED = 'canceled';
|
||||
case FAILED = 'failed';
|
||||
}
|
||||
@@ -26,6 +26,9 @@ class DeployService implements ShouldQueue
|
||||
public function handle(): void
|
||||
{
|
||||
$driver = $this->service->driver($this->defaultPassword);
|
||||
$this->service->update([
|
||||
'status' => ServiceStatus::INSTALLING
|
||||
]);
|
||||
$this->deployment = $this->service->deployments()->create([
|
||||
'status' => DeploymentStatus::PENDING,
|
||||
]);
|
||||
|
||||
@@ -70,4 +70,21 @@ class RunStep implements ShouldQueue
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(\Throwable $exception): void
|
||||
{
|
||||
$this->step->update([
|
||||
'status' => DeploymentStatus::FAILED,
|
||||
'finished_at' => now(),
|
||||
'logs' => $this->step->logs . "\n" . trim($exception->getMessage()),
|
||||
]);
|
||||
|
||||
$this->step->deployment->steps()->where('order', '>', $this->step->order)->update([
|
||||
'status' => DeploymentStatus::CANCELLED,
|
||||
]);
|
||||
|
||||
$this->step->deployment->update([
|
||||
'status' => DeploymentStatus::FAILED,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user