An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(sentinel): implement SentinelRestarted event and update Livewire components to handle server restart notifications
Andras Bacsai83f2e856ecfa
diff --git a/app/Actions/Server/StartSentinel.php b/app/Actions/Server/StartSentinel.phpindex 1ecf882dc4..dd1a7ed536 100644--- a/app/Actions/Server/StartSentinel.php+++ b/app/Actions/Server/StartSentinel.php@@ -2,6 +2,7 @@namespace App\Actions\Server;+use App\Events\SentinelRestarted;use App\Models\Server;use Lorisleiva\Actions\Concerns\AsAction;@@ -61,5 +62,8 @@ class StartSentinel$server->settings->is_sentinel_enabled = true;$server->settings->save();$server->sentinelHeartbeat();++ // Dispatch event to notify UI components+ SentinelRestarted::dispatch($server, $version);}}diff --git a/app/Events/SentinelRestarted.php b/app/Events/SentinelRestarted.phpnew file mode 100644index 0000000000..9ddc3a07f9--- /dev/null+++ b/app/Events/SentinelRestarted.php@@ -0,0 +1,39 @@+<?php++namespace App\Events;++use App\Models\Server;+use Illuminate\Broadcasting\InteractsWithSockets;+use Illuminate\Broadcasting\PrivateChannel;+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;+use Illuminate\Foundation\Events\Dispatchable;+use Illuminate\Queue\SerializesModels;++class SentinelRestarted implements ShouldBroadcast+{+ use Dispatchable, InteractsWithSockets, SerializesModels;++ public ?int $teamId = null;++ public ?string $version = null;++ public string $serverUuid;++ public function __construct(Server $server, ?string $version = null)+ {+ $this->teamId = $server->team_id;+ $this->serverUuid = $server->uuid;+ $this->version = $version;+ }++ public function broadcastOn(): array+ {+ if (is_null($this->teamId)) {+ return [];+ }++ return [+ new PrivateChannel("team.{$this->teamId}"),+ ];+ }+}diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.phpindex 70c5be5db4..f4ae6dd7e8 100644--- a/app/Livewire/Server/Show.php+++ b/app/Livewire/Server/Show.php@@ -67,8 +67,11 @@ class Show extends Componentpublic function getListeners(){+ $teamId = $this->server->team_id ?? auth()->user()->currentTeam()->id;+return ['refreshServerShow' => 'refresh',+ "echo-private:team.{$teamId},SentinelRestarted" => 'handleSentinelRestarted',];}@@ -221,6 +224,16 @@ class Show extends Component$this->syncData();}+ public function handleSentinelRestarted($event)+ {+ // Only refresh if the event is for this server+ if (isset($event['serverUuid']) && $event['serverUuid'] === $this->server->uuid) {+ $this->server->refresh();+ $this->syncData();+ $this->dispatch('success', 'Sentinel has been restarted successfully.');+ }+ }+public function validateServer($install = true){try {@@ -255,7 +268,7 @@ class Show extends Componenttry {$this->authorize('manageSentinel', $this->server);$this->server->restartSentinel();- $this->dispatch('success', 'Sentinel restarted.');+ $this->dispatch('success', 'Restarting Sentinel.');} catch (\Throwable $e) {return handleError($e, $this);}@@ -304,7 +317,7 @@ class Show extends Componenttry {$this->authorize('manageSentinel', $this->server);$this->server->settings->generateSentinelToken();- $this->dispatch('success', 'Token regenerated & Sentinel restarted.');+ $this->dispatch('success', 'Token regenerated. Restarting Sentinel.');} catch (\Throwable $e) {return handleError($e, $this);}diff --git a/app/Livewire/Source/Gitlab/Change.php b/app/Livewire/Source/Gitlab/Change.phpdeleted file mode 100644index 34600bb7dc..0000000000--- a/app/Livewire/Source/Gitlab/Change.php+++ /dev/null@@ -1,13 +0,0 @@-<?php--namespace App\Livewire\Source\Gitlab;--use Livewire\Component;--class Change extends Component-{- public function render()- {- return view('livewire.source.gitlab.change');- }-}