deployment failure status
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Services;
|
namespace App\Jobs\Services;
|
||||||
|
|
||||||
use App\Drivers\Driver;
|
|
||||||
use App\Enums\DeploymentStatus;
|
use App\Enums\DeploymentStatus;
|
||||||
use App\Enums\ServiceStatus;
|
use App\Enums\ServiceStatus;
|
||||||
|
use App\Models\Deployment;
|
||||||
use App\Models\Service;
|
use App\Models\Service;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
@@ -13,6 +13,8 @@ class DeployService implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
|
protected Deployment $deployment;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public Service $service,
|
public Service $service,
|
||||||
public ?string $defaultPassword = null,
|
public ?string $defaultPassword = null,
|
||||||
@@ -24,12 +26,11 @@ class DeployService implements ShouldQueue
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$driver = $this->service->driver($this->defaultPassword);
|
$driver = $this->service->driver($this->defaultPassword);
|
||||||
/** @var \App\Models\Deployment $deployment */
|
$this->deployment = $this->service->deployments()->create([
|
||||||
$deployment = $this->service->deployments()->create([
|
|
||||||
'status' => DeploymentStatus::PENDING,
|
'status' => DeploymentStatus::PENDING,
|
||||||
]);
|
]);
|
||||||
foreach ($driver->deploymentPlan->steps as $index => $plannedStep) {
|
foreach ($driver->deploymentPlan->steps as $index => $plannedStep) {
|
||||||
$step = $deployment->steps()->create([
|
$step = $this->deployment->steps()->create([
|
||||||
'order' => $index + 1,
|
'order' => $index + 1,
|
||||||
'status' => DeploymentStatus::PENDING,
|
'status' => DeploymentStatus::PENDING,
|
||||||
'script' => $plannedStep->getSafeScript(),
|
'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