From 9c80324f5c121b83bb84d9ebc26f76c468e3fbfc Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Mon, 2 Oct 2023 10:46:53 -0700 Subject: [PATCH] Fallback port in use Summary: If no version information is obtained, check if port is in use. This is for the cases in which an older server which may not have implemented this endpoint fails to return version information. In this case, send the shutdown command. Reviewed By: antonk52 Differential Revision: D49830759 fbshipit-source-id: 6c9763d01f335ecc8a28df3b90d319f98016c2da --- desktop/flipper-server/src/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index df5db7f9d..ef87bee3c 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -20,6 +20,7 @@ import open from 'open'; import os from 'os'; import {initCompanionEnv} from 'flipper-server-companion'; import { + checkPortInUse, checkServerRunning, compareServerVersion, getEnvironmentInfo, @@ -167,6 +168,11 @@ async function start() { } else { launchAndFinish = true; } + } else { + if (await checkPortInUse(argv.port)) { + console.info('[flipper-server] Checking if port is in use'); + await shutdownRunningInstance(argv.port); + } } const t3 = performance.now();