lasthourcloud/app/Console/Commands/Init.php

34 lines
925 B
PHP
Raw Normal View History

2023-06-30 09:42:59 +00:00
<?php
namespace App\Console\Commands;
2023-06-30 20:26:40 +00:00
use App\Enums\ApplicationDeploymentStatus;
2023-06-30 09:42:59 +00:00
use App\Models\ApplicationDeploymentQueue;
use Illuminate\Console\Command;
class Init extends Command
{
protected $signature = 'app:init';
protected $description = 'Cleanup instance related stuffs';
2023-06-30 09:42:59 +00:00
public function handle()
{
2023-06-30 20:26:40 +00:00
$this->cleanup_in_progress_application_deployments();
}
2023-06-30 20:26:40 +00:00
private function cleanup_in_progress_application_deployments()
{
// Cleanup any failed deployments
2023-06-30 09:42:59 +00:00
try {
$halted_deployments = ApplicationDeploymentQueue::where('status', '==', 'in_progress')->get();
2023-06-30 20:26:40 +00:00
foreach ($halted_deployments as $deployment) {
$deployment->status = ApplicationDeploymentStatus::FAILED->value;
$deployment->save();
}
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
2023-06-30 09:42:59 +00:00
echo "Error: {$e->getMessage()}\n";
}
}
}