Skip to content

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.

fix: double ws connection

Andras Bacsai6bb79e10bce9
diff --git a/app/Actions/CoolifyTask/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.php
index ef0c9e59b4..327d46c68f 100644
--- a/app/Actions/CoolifyTask/RunRemoteProcess.php
+++ b/app/Actions/CoolifyTask/RunRemoteProcess.php
@@ -27,7 +27,7 @@ class RunRemoteProcess
protected $last_write_at = 0;
- protected $throttle_interval_ms = 500;
+ protected $throttle_interval_ms = 200;
protected int $counter = 1;
@@ -74,8 +74,14 @@ class RunRemoteProcess
$this->time_start = hrtime(true);
$status = ProcessStatus::IN_PROGRESS;
- $processResult = Process::forever()->run($this->getCommand(), $this->handleOutput(...));
+ $timeout = config('constants.ssh.command_timeout');
+ $process = Process::timeout($timeout)->start($this->getCommand(), $this->handleOutput(...));
+ $this->activity->properties = $this->activity->properties->merge([
+ 'process_id' => $process->id(),
+ ]);
+ $processResult = $process->wait();
+ // $processResult = Process::timeout($timeout)->run($this->getCommand(), $this->handleOutput(...));
if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) {
$status = ProcessStatus::ERROR;
} else {
@@ -131,7 +137,6 @@ class RunRemoteProcess
}
$this->current_time = $this->elapsedTime();
$this->activity->description = $this->encodeOutput($type, $output);
-
if ($this->isAfterLastThrottle()) {
// Let's write to database.
DB::transaction(function () {
diff --git a/app/Data/CoolifyTaskArgs.php b/app/Data/CoolifyTaskArgs.php
index 584fadb98c..cc717561ff 100644
--- a/app/Data/CoolifyTaskArgs.php
+++ b/app/Data/CoolifyTaskArgs.php
@@ -16,6 +16,7 @@ class CoolifyTaskArgs extends Data
public string $command,
public string $type,
public ?string $type_uuid = null,
+ public ?int $process_id = null,
public ?Model $model = null,
public ?string $status = null ,
public bool $ignore_errors = false,
diff --git a/app/Enums/ProcessStatus.php b/app/Enums/ProcessStatus.php
index 889aca9f2c..0031cabdd2 100644
--- a/app/Enums/ProcessStatus.php
+++ b/app/Enums/ProcessStatus.php
@@ -8,5 +8,6 @@ enum ProcessStatus: string
case IN_PROGRESS = 'in_progress';
case FINISHED = 'finished';
case ERROR = 'error';
+ case KILLED = 'killed';
case CANCELLED = 'cancelled';
}
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index ca5d427c59..47bc35b5d5 100644
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -11,4 +11,46 @@
<main class="pb-10 main max-w-screen-2xl">
{{ $slot }}
</main>
+ <script data-navigate-once>
+ @auth
+ window.Pusher = Pusher;
+ window.Echo = new Echo({
+ broadcaster: 'pusher',
+ cluster: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
+ key: "{{ env('PUSHER_APP_KEY') }}" || 'coolify',
+ wsHost: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
+ wsPort: "{{ env('PUSHER_PORT') }}" || 6001,
+ wssPort: "{{ env('PUSHER_PORT') }}" || 6001,
+ forceTLS: false,
+ encrypted: true,
+ enableStats: false,
+ enableLogging: true,
+ enabledTransports: ['ws', 'wss'],
+ });
+
+ if ("{{ auth()->user()->id }}" == 0) {
+ let checkPusherInterval = null;
+ let checkNumber = 0;
+ let errorMessage =
+ "Coolify could not connect to the new realtime service introduced in beta.154.<br>Please check the related <a href='https://coolify.io/docs/cloudflare-tunnels' target='_blank'>documentation</a> or get help on <a href='https://coollabs.io/discord' target='_blank'>Discord</a>.";
+ checkPusherInterval = setInterval(() => {
+ if (window.Echo) {
+ if (window.Echo.connector.pusher.connection.state !== 'connected') {
+ checkNumber++;
+ if (checkNumber > 5) {
+ clearInterval(checkPusherInterval);
+ Livewire.emit('error', errorMessage);
+ }
+ } else {
+ console.log('Coolify is now connected to the new realtime service introduced in beta.154.');
+ clearInterval(checkPusherInterval);
+ }
+ } else {
+ clearInterval(checkPusherInterval);
+ Livewire.emit('error', errorMessage);
+ }
+ }, 2000);
+ }
+ @endauth
+ </script>
@endsection
diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php
index c6a5d6edca..40464ef46a 100644
--- a/resources/views/layouts/base.blade.php
+++ b/resources/views/layouts/base.blade.php
@@ -46,46 +46,6 @@
<x-version class="fixed left-2 bottom-1" />
<script data-navigate-once>
- @auth
- window.Pusher = Pusher;
- window.Echo = new Echo({
- broadcaster: 'pusher',
- cluster: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
- key: "{{ env('PUSHER_APP_KEY') }}" || 'coolify',
- wsHost: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
- wsPort: "{{ env('PUSHER_PORT') }}" || 6001,
- wssPort: "{{ env('PUSHER_PORT') }}" || 6001,
- forceTLS: false,
- encrypted: true,
- enableStats: false,
- enableLogging: true,
- enabledTransports: ['ws', 'wss'],
- });
-
- if ("{{ auth()->user()->id }}" == 0) {
- let checkPusherInterval = null;
- let checkNumber = 0;
- let errorMessage =
- "Coolify could not connect to the new realtime service introduced in beta.154.<br>Please check the related <a href='https://coolify.io/docs/cloudflare-tunnels' target='_blank'>documentation</a> or get help on <a href='https://coollabs.io/discord' target='_blank'>Discord</a>.";
- checkPusherInterval = setInterval(() => {
- if (window.Echo) {
- if (window.Echo.connector.pusher.connection.state !== 'connected') {
- checkNumber++;
- if (checkNumber > 5) {
- clearInterval(checkPusherInterval);
- Livewire.emit('error', errorMessage);
- }
- } else {
- console.log('Coolify is now connected to the new realtime service introduced in beta.154.');
- clearInterval(checkPusherInterval);
- }
- } else {
- clearInterval(checkPusherInterval);
- Livewire.emit('error', errorMessage);
- }
- }, 2000);
- }
- @endauth
let checkHealthInterval = null;
let checkIfIamDeadInterval = null;
diff --git a/resources/views/livewire/activity-monitor.blade.php b/resources/views/livewire/activity-monitor.blade.php
index 97d3bd64c4..69a8c0f33f 100644
--- a/resources/views/livewire/activity-monitor.blade.php
+++ b/resources/views/livewire/activity-monitor.blade.php
@@ -12,7 +12,7 @@
<div
class="scrollbar flex flex-col-reverse w-full overflow-y-auto border border-solid rounded border-coolgray-300 max-h-[32rem] p-4 pt-6 text-xs text-white">
- <pre class="font-mono whitespace-pre-wrap" @if ($isPollingActive) wire:poll.2000ms="polling" @endif>{{ RunRemoteProcess::decodeOutput($this->activity) }}</pre>
+ <pre class="font-mono whitespace-pre-wrap" @if ($isPollingActive) wire:poll.1000ms="polling" @endif>{{ RunRemoteProcess::decodeOutput($this->activity) }}</pre>
</div>
@endif
</div>