application = Application::find($applicationId)->first(); $this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first(); } public function render() { return view('livewire.deploy-application'); } public function start() { // Create Deployment ID $this->deployment_uuid = new Cuid2(7); dispatch(new DeployApplicationJob( deployment_uuid: $this->deployment_uuid, application_uuid: $this->application->uuid, )); $currentUrl = url()->previous(); $deploymentUrl = "$currentUrl/deployment/$this->deployment_uuid"; return redirect($deploymentUrl); } public function stop() { runRemoteCommandSync($this->destination->server, ["docker stop -t 0 {$this->application->uuid} >/dev/null 2>&1"]); $this->application->status = 'stopped'; $this->application->save(); } public function kill() { runRemoteCommandSync($this->destination->server, ["docker rm -f {$this->application->uuid}"]); if ($this->application->status != 'exited') { $this->application->status = 'exited'; $this->application->save(); } } public function pollingStatus() { $this->application->refresh(); } }