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
fix: database ui is realtime based
Andras Bacsai720bb8c4786d
diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.phpindex 21fcdb8a5e..5ea86a5514 100644--- a/app/Actions/Database/StartMariadb.php+++ b/app/Actions/Database/StartMariadb.php@@ -105,7 +105,7 @@ class StartMariadb$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo '{$database->name} started.'";- return remote_process($this->commands, $database->destination->server);+ return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.phpindex e0197a7bcf..9ce35bbc28 100644--- a/app/Actions/Database/StartMongodb.php+++ b/app/Actions/Database/StartMongodb.php@@ -121,7 +121,7 @@ class StartMongodb$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo '{$database->name} started.'";- return remote_process($this->commands, $database->destination->server);+ return remote_process($this->commands, $database->destination->server,callEventOnFinish: 'DatabaseStatusChanged');}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.phpindex 76e8af6193..d37821332d 100644--- a/app/Actions/Database/StartMysql.php+++ b/app/Actions/Database/StartMysql.php@@ -105,7 +105,7 @@ class StartMysql$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo '{$database->name} started.'";- return remote_process($this->commands, $database->destination->server);+ return remote_process($this->commands, $database->destination->server,callEventOnFinish: 'DatabaseStatusChanged');}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpindex 97ae9da0e4..99fb56ba4a 100644--- a/app/Actions/Database/StartPostgresql.php+++ b/app/Actions/Database/StartPostgresql.php@@ -131,7 +131,7 @@ class StartPostgresql$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo '{$database->name} started.'";- return remote_process($this->commands, $database->destination->server);+ return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.phpindex fcb87b8915..4e3773726c 100644--- a/app/Actions/Database/StartRedis.php+++ b/app/Actions/Database/StartRedis.php@@ -115,7 +115,7 @@ class StartRedis$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml pull";$this->commands[] = "docker compose -f $this->configuration_dir/docker-compose.yml up -d";$this->commands[] = "echo '{$database->name} started.'";- return remote_process($this->commands, $database->destination->server);+ return remote_process($this->commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged');}private function generate_local_persistent_volumes()diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.phpindex 4f6a8c6c2c..e6316ecc99 100644--- a/app/Actions/Database/StopDatabase.php+++ b/app/Actions/Database/StopDatabase.php@@ -2,6 +2,7 @@namespace App\Actions\Database;+use App\Events\DatabaseStatusChanged;use App\Models\StandaloneMariadb;use App\Models\StandaloneMongodb;use App\Models\StandaloneMysql;diff --git a/app/Events/DatabaseStatusChanged.php b/app/Events/DatabaseStatusChanged.phpnew file mode 100644index 0000000000..9c1e54cfda--- /dev/null+++ b/app/Events/DatabaseStatusChanged.php@@ -0,0 +1,34 @@+<?php++namespace App\Events;++use Illuminate\Broadcasting\Channel;+use Illuminate\Broadcasting\InteractsWithSockets;+use Illuminate\Broadcasting\PresenceChannel;+use Illuminate\Broadcasting\PrivateChannel;+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;+use Illuminate\Foundation\Events\Dispatchable;+use Illuminate\Queue\SerializesModels;++class DatabaseStatusChanged implements ShouldBroadcast+{+ use Dispatchable, InteractsWithSockets, SerializesModels;+ public $userId;+ public function __construct($userId = null)+ {+ if (is_null($userId)) {+ $userId = auth()->user()->id ?? null;+ }+ if (is_null($userId)) {+ throw new \Exception("User id is null");+ }+ $this->userId = $userId;+ }++ public function broadcastOn(): array+ {+ return [+ new PrivateChannel("custom.{$this->userId}"),+ ];+ }+}diff --git a/app/Livewire/Project/Database/Heading.php b/app/Livewire/Project/Database/Heading.phpindex 3e54426775..1c94f9573d 100644--- a/app/Livewire/Project/Database/Heading.php+++ b/app/Livewire/Project/Database/Heading.php@@ -8,6 +8,7 @@ use App\Actions\Database\StartMysql;use App\Actions\Database\StartPostgresql;use App\Actions\Database\StartRedis;use App\Actions\Database\StopDatabase;+use App\Events\DatabaseStatusChanged;use App\Jobs\ContainerStatusJob;use Livewire\Component;@@ -16,7 +17,13 @@ class Heading extends Componentpublic $database;public array $parameters;- protected $listeners = ['activityFinished'];+ public function getListeners()+ {+ $userId = auth()->user()->id;+ return [+ "echo-private:custom.{$userId},DatabaseStatusChanged" => 'activityFinished',+ ];+ }public function activityFinished(){