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
This commit is contained in:
Lorenzo Blasa
2023-10-02 10:46:53 -07:00
committed by Facebook GitHub Bot
parent 3c73074e29
commit 9c80324f5c

View File

@@ -20,6 +20,7 @@ import open from 'open';
import os from 'os'; import os from 'os';
import {initCompanionEnv} from 'flipper-server-companion'; import {initCompanionEnv} from 'flipper-server-companion';
import { import {
checkPortInUse,
checkServerRunning, checkServerRunning,
compareServerVersion, compareServerVersion,
getEnvironmentInfo, getEnvironmentInfo,
@@ -167,6 +168,11 @@ async function start() {
} else { } else {
launchAndFinish = true; 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(); const t3 = performance.now();