diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php
index 5fc75d859..7260ec5fc 100644
--- a/app/Console/Commands/Init.php
+++ b/app/Console/Commands/Init.php
@@ -14,13 +14,19 @@ use Illuminate\Support\Facades\Http;
class Init extends Command
{
- protected $signature = 'app:init {--full-cleanup}';
+ protected $signature = 'app:init {--full-cleanup} {--cleanup-deployments}';
protected $description = 'Cleanup instance related stuffs';
public function handle()
{
$this->alive();
$full_cleanup = $this->option('full-cleanup');
+ $cleanup_deployments = $this->option('cleanup-deployments');
+ if ($cleanup_deployments) {
+ echo "Running cleanup deployments.\n";
+ $this->cleanup_in_progress_application_deployments();
+ return;
+ }
if ($full_cleanup) {
echo "Running init cleanupsg.\n";
@@ -122,8 +128,9 @@ class Init extends Command
// Cleanup any failed deployments
try {
- $halted_deployments = ApplicationDeploymentQueue::where('status', '==', ApplicationDeploymentStatus::IN_PROGRESS)->where('status', '==', ApplicationDeploymentStatus::QUEUED)->get();
- foreach ($halted_deployments as $deployment) {
+ $queued_inprogress_deployments = ApplicationDeploymentQueue::whereIn('status', [ApplicationDeploymentStatus::IN_PROGRESS->value, ApplicationDeploymentStatus::QUEUED->value])->get();
+ foreach ($queued_inprogress_deployments as $deployment) {
+ ray($deployment->id, $deployment->status);
echo "Cleaning up deployment: {$deployment->id}\n";
$deployment->status = ApplicationDeploymentStatus::FAILED->value;
$deployment->save();
diff --git a/app/Livewire/Dashboard.php b/app/Livewire/Dashboard.php
index b282cb175..696ae09c4 100644
--- a/app/Livewire/Dashboard.php
+++ b/app/Livewire/Dashboard.php
@@ -6,6 +6,7 @@ use App\Models\ApplicationDeploymentQueue;
use App\Models\Project;
use App\Models\Server;
use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Artisan;
use Livewire\Component;
class Dashboard extends Component
@@ -19,6 +20,12 @@ class Dashboard extends Component
$this->projects = Project::ownedByCurrentTeam()->get();
$this->get_deployments();
}
+ public function cleanup_queue()
+ {
+ Artisan::queue('app:init', [
+ '--cleanup-deployments' => 'true'
+ ]);
+ }
public function get_deployments()
{
$this->deployments_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn("server_id", $this->servers->pluck("id"))->get([
diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php
index 143efc339..77e92ac6c 100644
--- a/resources/views/livewire/dashboard.blade.php
+++ b/resources/views/livewire/dashboard.blade.php
@@ -106,6 +106,7 @@
@if (count($deployments_per_server) > 0)