Skip to content

Commit

Permalink
feat: experimental sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed May 7, 2024
1 parent 2b422a5 commit f6f959a
Show file tree
Hide file tree
Showing 13 changed files with 1,038 additions and 327 deletions.
655 changes: 655 additions & 0 deletions app/Actions/Docker/GetContainersStatus.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/Jobs/ApplicationDeploymentJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Jobs;

use App\Actions\Docker\GetContainersStatus;
use App\Enums\ApplicationDeploymentStatus;
use App\Enums\ProcessStatus;
use App\Events\ApplicationStatusChanged;
Expand Down Expand Up @@ -302,7 +303,8 @@ private function post_deployment()
{

if ($this->server->isProxyShouldRun()) {
dispatch(new ContainerStatusJob($this->server));
GetContainersStatus::dispatch($this->server);
// dispatch(new ContainerStatusJob($this->server));
}
$this->next(ApplicationDeploymentStatus::FINISHED->value);
if ($this->pull_request_id !== 0) {
Expand Down
632 changes: 313 additions & 319 deletions app/Jobs/ContainerStatusJob.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/Livewire/Project/Application/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Livewire\Project\Application;

use App\Actions\Application\StopApplication;
use App\Actions\Docker\GetContainersStatus;
use App\Events\ApplicationStatusChanged;
use App\Jobs\ContainerStatusJob;
use App\Jobs\ServerStatusJob;
Expand Down Expand Up @@ -32,7 +33,8 @@ public function mount()
public function check_status($showNotification = false)
{
if ($this->application->destination->server->isFunctional()) {
dispatch(new ContainerStatusJob($this->application->destination->server));
GetContainersStatus::dispatch($this->application->destination->server);
// dispatch(new ContainerStatusJob($this->application->destination->server));
} else {
dispatch(new ServerStatusJob($this->application->destination->server));
}
Expand Down
4 changes: 3 additions & 1 deletion app/Livewire/Project/Database/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Actions\Database\StartPostgresql;
use App\Actions\Database\StartRedis;
use App\Actions\Database\StopDatabase;
use App\Actions\Docker\GetContainersStatus;
use App\Jobs\ContainerStatusJob;
use Livewire\Component;

Expand Down Expand Up @@ -44,7 +45,8 @@ public function activityFinished()

public function check_status($showNotification = false)
{
dispatch_sync(new ContainerStatusJob($this->database->destination->server));
GetContainersStatus::run($this->application->destination->server);
// dispatch_sync(new ContainerStatusJob($this->database->destination->server));
$this->database->refresh();
if ($showNotification) $this->dispatch('success', 'Database status updated.');
}
Expand Down
4 changes: 3 additions & 1 deletion app/Livewire/Project/Service/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Livewire\Project\Service;

use App\Actions\Docker\GetContainersStatus;
use App\Jobs\ContainerStatusJob;
use App\Models\Service;
use Livewire\Component;
Expand Down Expand Up @@ -64,7 +65,8 @@ public function restartDatabase($id)
public function check_status()
{
try {
dispatch_sync(new ContainerStatusJob($this->service->server));
GetContainersStatus::run($this->service->server);
// dispatch_sync(new ContainerStatusJob($this->service->server));
$this->dispatch('refresh')->self();
$this->dispatch('updateStatus');
} catch (\Exception $e) {
Expand Down
4 changes: 3 additions & 1 deletion app/Livewire/Project/Shared/Destination.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Livewire\Project\Shared;

use App\Actions\Application\StopApplicationOneServer;
use App\Actions\Docker\GetContainersStatus;
use App\Events\ApplicationStatusChanged;
use App\Jobs\ContainerStatusJob;
use App\Models\Server;
Expand Down Expand Up @@ -90,7 +91,8 @@ public function promote(int $network_id, int $server_id)
}
public function refreshServers()
{
ContainerStatusJob::dispatchSync($this->resource->destination->server);
GetContainersStatus::run($this->resource->destination->server);
// ContainerStatusJob::dispatchSync($this->resource->destination->server);
$this->loadData();
$this->dispatch('refresh');
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
Expand Down
4 changes: 3 additions & 1 deletion app/Livewire/Server/Proxy/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Livewire\Server\Proxy;

use App\Actions\Docker\GetContainersStatus;
use App\Actions\Proxy\CheckProxy;
use App\Jobs\ContainerStatusJob;
use App\Models\Server;
Expand Down Expand Up @@ -49,7 +50,8 @@ public function checkProxy(bool $notification = false)
public function getProxyStatus()
{
try {
dispatch_sync(new ContainerStatusJob($this->server));
GetContainersStatus::run($this->server);
// dispatch_sync(new ContainerStatusJob($this->server));
$this->dispatch('proxyStatusUpdated');
} catch (\Throwable $e) {
return handleError($e, $this);
Expand Down
4 changes: 3 additions & 1 deletion app/Notifications/Server/Revived.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Notifications\Server;

use App\Actions\Docker\GetContainersStatus;
use App\Jobs\ContainerStatusJob;
use App\Models\Server;
use Illuminate\Bus\Queueable;
Expand All @@ -22,7 +23,8 @@ public function __construct(public Server $server)
if ($this->server->unreachable_notification_sent === false) {
return;
}
dispatch(new ContainerStatusJob($server));
GetContainersStatus::dispatch($server);
// dispatch(new ContainerStatusJob($server));
}

public function via(object $notifiable): array
Expand Down
28 changes: 28 additions & 0 deletions database/migrations/2024_05_07_124019_add_server_metrics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('servers', function (Blueprint $table) {
$table->boolean('is_metrics_enabled')->default(true);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('is_metrics_enabled');
});
}
};
6 changes: 6 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ services:
PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
volumes:
- .:/var/www/html/:cached
sentinel:
ports:
- "127.0.0.1:8888:8888"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- .:/var/www/html/:cached
postgres:
pull_policy: always
ports:
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ services:
condition: service_healthy
redis:
condition: service_healthy
sentinel:
image: "ghcr.io/coollabsio/sentinel:${LATEST_IMAGE:-latest}"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /data/coolify/metrics:/var/www/html/storage/app/metrics
ports:
- "127.0.0.1:8888:8888"
healthcheck:
test: curl --fail http://127.0.0.1:8888/api/health || exit 1
postgres:
volumes:
- coolify-db:/var/lib/postgresql/data
Expand Down
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ services:
depends_on:
- postgres
- redis

sentinel:
image: "ghcr.io/coollabsio/sentinel:latest"
container_name: coolify-sentinel
restart: always
networks:
- coolify
postgres:
image: postgres:15-alpine
container_name: coolify-db
Expand Down

0 comments on commit f6f959a

Please sign in to comment.