coolify/app/Console/Commands/Init.php

34 lines
925 B
PHP
Raw Normal View History

2023-06-30 11:42:59 +02:00
<?php
namespace App\Console\Commands;
2023-06-30 22:26:40 +02:00
use App\Enums\ApplicationDeploymentStatus;
2023-06-30 11:42:59 +02: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 11:42:59 +02:00
public function handle()
{
2023-06-30 22:26:40 +02:00
$this->cleanup_in_progress_application_deployments();
}
2023-06-30 22:26:40 +02:00
private function cleanup_in_progress_application_deployments()
{
// Cleanup any failed deployments
2023-06-30 11:42:59 +02:00
try {
$halted_deployments = ApplicationDeploymentQueue::where('status', '==', 'in_progress')->get();
2023-06-30 22:26:40 +02:00
foreach ($halted_deployments as $deployment) {
$deployment->status = ApplicationDeploymentStatus::FAILED->value;
$deployment->save();
}
2023-09-11 17:36:30 +02:00
} catch (\Throwable $e) {
2023-06-30 11:42:59 +02:00
echo "Error: {$e->getMessage()}\n";
}
}
}