lasthourcloud/app/Console/Commands/Init.php

32 lines
923 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';
public function handle()
{
2023-06-30 20:26:40 +00:00
$this->cleanup_in_progress_application_deployments();
}
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-06-30 09:42:59 +00:00
} catch (\Exception $e) {
echo "Error: {$e->getMessage()}\n";
}
}
}