This commit is contained in:
Andras Bacsai 2023-11-05 09:49:23 +01:00
parent 0a5a101ef4
commit 6f673d7a07
6 changed files with 10 additions and 8 deletions

View File

@ -4,7 +4,6 @@ namespace App\Actions\Service;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
use App\Models\Service; use App\Models\Service;
use App\Notifications\Application\StatusChanged;
class StopService class StopService
{ {

View File

@ -13,7 +13,7 @@ class Index extends Component
public $databases; public $databases;
public array $parameters; public array $parameters;
public array $query; public array $query;
protected $listeners = ["refreshStacks"]; protected $listeners = ["refreshStacks", "checkStatus"];
public function render() public function render()
{ {
return view('livewire.project.service.index'); return view('livewire.project.service.index');

View File

@ -4,7 +4,6 @@ namespace App\Http\Livewire\Project\Service;
use App\Actions\Service\StartService; use App\Actions\Service\StartService;
use App\Actions\Service\StopService; use App\Actions\Service\StopService;
use App\Jobs\ContainerStatusJob;
use App\Models\Service; use App\Models\Service;
use Livewire\Component; use Livewire\Component;
@ -13,12 +12,15 @@ class Navbar extends Component
public Service $service; public Service $service;
public array $parameters; public array $parameters;
public array $query; public array $query;
protected $listeners = ["checkStatus"];
public function render() public function render()
{ {
return view('livewire.project.service.navbar'); return view('livewire.project.service.navbar');
} }
public function checkStatus() {
$this->service->refresh();
}
public function deploy() public function deploy()
{ {
$this->service->parse(); $this->service->parse();
@ -30,6 +32,6 @@ class Navbar extends Component
StopService::run($this->service); StopService::run($this->service);
$this->service->refresh(); $this->service->refresh();
$this->emit('success', 'Service stopped successfully.'); $this->emit('success', 'Service stopped successfully.');
$this->checkStatus(); $this->emit('checkStatus');
} }
} }

View File

@ -25,6 +25,9 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
public function __construct(public Server $server) public function __construct(public Server $server)
{ {
if (isDev()) {
$this->handle();
}
} }
public function middleware(): array public function middleware(): array
{ {

View File

@ -57,11 +57,10 @@ class StopResourceJob implements ShouldQueue, ShouldBeEncrypted
StopService::run($this->resource); StopService::run($this->resource);
break; break;
} }
$this->resource->delete();
} catch (\Throwable $e) { } catch (\Throwable $e) {
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage()); send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
throw $e; throw $e;
} finally {
$this->resource->delete();
} }
} }
} }

View File

@ -40,7 +40,6 @@ class Service extends BaseModel
instant_remote_process(["docker volume rm -f $storage->name"], $service->server, false); instant_remote_process(["docker volume rm -f $storage->name"], $service->server, false);
}); });
} }
instant_remote_process(["docker network rm {$service->uuid}"], $service->server, false);
}); });
} }
public function type() public function type()