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-08-08 09:51:36 +00:00
|
|
|
|
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-08-08 09:51:36 +00:00
|
|
|
|
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-06-30 09:42:59 +00:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo "Error: {$e->getMessage()}\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|