From bfe55c12a79b10f8e5b3f433eef20097aef1dffb Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 30 Jun 2023 22:26:40 +0200 Subject: [PATCH] wip --- app/Console/Commands/Init.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 45ac000c9..32ff31827 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -2,33 +2,28 @@ namespace App\Console\Commands; +use App\Enums\ApplicationDeploymentStatus; use App\Models\ApplicationDeploymentQueue; use Illuminate\Console\Command; class Init extends Command { - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'app:init'; - - /** - * The console command description. - * - * @var string - */ protected $description = 'Cleanup instance related stuffs'; - - /** - * Execute the console command. - */ public function handle() { + $this->cleanup_in_progress_application_deployments(); + } + private function cleanup_in_progress_application_deployments() + { + // Cleanup any failed deployments + try { $halted_deployments = ApplicationDeploymentQueue::where('status', '==', 'in_progress')->get(); - ray($halted_deployments); + foreach ($halted_deployments as $deployment) { + $deployment->status = ApplicationDeploymentStatus::FAILED->value; + $deployment->save(); + } } catch (\Exception $e) { echo "Error: {$e->getMessage()}\n"; }