This commit is contained in:
Andras Bacsai
2023-05-31 12:38:36 +02:00
parent c953482ba9
commit 59f631e1d4
12 changed files with 73 additions and 55 deletions

View File

@@ -20,12 +20,20 @@ class Deploy extends Component
protected array $command = [];
protected $source;
protected $listeners = [
'applicationStatusChanged' => 'applicationStatusChanged',
];
public function mount()
{
$this->parameters = get_parameters();
$this->application = Application::where('id', $this->applicationId)->first();
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
}
public function applicationStatusChanged()
{
$this->application->refresh();
}
protected function set_deployment_uuid()
{
// Create Deployment ID

View File

@@ -3,16 +3,17 @@
namespace App\Http\Livewire\Project\Application;
use App\Enums\ActivityTypes;
use App\Models\Application;
use Illuminate\Support\Facades\Redis;
use Livewire\Component;
use Spatie\Activitylog\Models\Activity;
class DeploymentLogs extends Component
{
public Application $application;
public $activity;
public $isKeepAliveOn = true;
public $deployment_uuid;
public function polling()
{
if (is_null($this->activity) && isset($this->deployment_uuid)) {

View File

@@ -6,9 +6,8 @@ use App\Enums\ProcessStatus;
use App\Models\Application;
use App\Models\ApplicationDeploymentQueue;
use Livewire\Component;
use Spatie\Activitylog\Contracts\Activity;
class DeploymentCancel extends Component
class DeploymentNavbar extends Component
{
public Application $application;
public $activity;
@@ -16,17 +15,23 @@ class DeploymentCancel extends Component
public function cancel()
{
try {
ray('Cancelling deployment: ' . $this->deployment_uuid . 'of application: ' . $this->application->uuid);
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->firstOrFail();
$deployment->status = 'cancelled';
ray('Cancelling deployment: ' . $this->deployment_uuid . ' of application: ' . $this->application->uuid);
// Update deployment queue
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
$deployment->status = 'cancelled by user';
$deployment->save();
// Update activity
$this->activity->properties = $this->activity->properties->merge([
'exitCode' => 1,
'status' => ProcessStatus::CANCELLED->value,
]);
$this->activity->save();
instant_remote_process(["docker rm -f {$this->deployment_uuid}"], $this->application->destination->server, throwError: false);
// Remove builder container
instant_remote_process(["docker rm -f {$this->deployment_uuid}"], $this->application->destination->server, throwError: false, repeat: 25);
queue_next_deployment($this->application);
} catch (\Throwable $th) {
return general_error_handler($th, $this);
}

View File

@@ -9,11 +9,9 @@ class Status extends Component
{
public Application $application;
protected $listeners = [
'applicationStatusChanged' => 'pollingStatus',
];
public function pollingStatus()
public function applicationStatusChanged()
{
$this->emit('applicationStatusChanged');
$this->application->refresh();
}
}