lasthourcloud/app/Console/Commands/CleanupApplicationDeploymentQueue.php

27 lines
906 B
PHP
Raw Permalink Normal View History

2024-02-26 13:22:24 +00:00
<?php
namespace App\Console\Commands;
use App\Models\ApplicationDeploymentQueue;
use Illuminate\Console\Command;
class CleanupApplicationDeploymentQueue extends Command
{
protected $signature = 'cleanup:application-deployment-queue {--team-id=}';
2024-06-10 20:43:34 +00:00
2024-02-26 13:22:24 +00:00
protected $description = 'CleanupApplicationDeploymentQueue';
public function handle()
{
$team_id = $this->option('team-id');
$servers = \App\Models\Server::where('team_id', $team_id)->get();
foreach ($servers as $server) {
2024-06-10 20:43:34 +00:00
$deployments = ApplicationDeploymentQueue::whereIn('status', ['in_progress', 'queued'])->where('server_id', $server->id)->get();
2024-02-26 13:22:24 +00:00
foreach ($deployments as $deployment) {
$deployment->update(['status' => 'failed']);
2024-06-10 20:43:34 +00:00
instant_remote_process(['docker rm -f '.$deployment->deployment_uuid], $server, false);
2024-02-26 13:22:24 +00:00
}
}
}
}