From 28bcd0023cc442dcad604f25fa368ba0c7129ab6 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:33:57 +0200 Subject: [PATCH] remove cache --- .../CleanupStaleMultiplexedConnections.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/Jobs/CleanupStaleMultiplexedConnections.php b/app/Jobs/CleanupStaleMultiplexedConnections.php index 733adb8d4..bcca77c18 100644 --- a/app/Jobs/CleanupStaleMultiplexedConnections.php +++ b/app/Jobs/CleanupStaleMultiplexedConnections.php @@ -25,19 +25,13 @@ class CleanupStaleMultiplexedConnections implements ShouldQueue private function cleanupStaleConnection(Server $server) { - $cacheKey = "mux_connection_{$server->id}"; - $cachedConnection = cache()->get($cacheKey); + $muxSocket = "/tmp/mux_{$server->id}"; + $checkCommand = "ssh -O check -o ControlPath=$muxSocket {$server->user}@{$server->ip} 2>/dev/null"; + $checkProcess = Process::run($checkCommand); - if ($cachedConnection) { - $muxSocket = $cachedConnection['muxSocket']; - $checkCommand = "ssh -O check -o ControlPath=$muxSocket {$server->user}@{$server->ip} 2>/dev/null"; - $checkProcess = Process::run($checkCommand); - - if ($checkProcess->exitCode() !== 0) { - $closeCommand = "ssh -O exit -o ControlPath=$muxSocket {$server->user}@{$server->ip} 2>/dev/null"; - Process::run($closeCommand); - cache()->forget($cacheKey); - } + if ($checkProcess->exitCode() !== 0) { + $closeCommand = "ssh -O exit -o ControlPath=$muxSocket {$server->user}@{$server->ip} 2>/dev/null"; + Process::run($closeCommand); } } }