fix: double ws connection
This commit is contained in:
parent
ba2e4c06f1
commit
6bb79e10bc
@ -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 @@ public function __invoke(): ProcessResult
|
||||
$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 @@ protected function handleOutput(string $type, string $output)
|
||||
}
|
||||
$this->current_time = $this->elapsedTime();
|
||||
$this->activity->description = $this->encodeOutput($type, $output);
|
||||
|
||||
if ($this->isAfterLastThrottle()) {
|
||||
// Let's write to database.
|
||||
DB::transaction(function () {
|
||||
|
@ -16,6 +16,7 @@ public function __construct(
|
||||
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,
|
||||
|
@ -8,5 +8,6 @@ enum ProcessStatus: string
|
||||
case IN_PROGRESS = 'in_progress';
|
||||
case FINISHED = 'finished';
|
||||
case ERROR = 'error';
|
||||
case KILLED = 'killed';
|
||||
case CANCELLED = 'cancelled';
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user