UDS/TCP options
Summary: Provide an option to enable/disable TCP connections on flipper-server. The only change at this stage is that Flipper Desktop will use UDS to connect to flipper-server. Reviewed By: passy Differential Revision: D37519656 fbshipit-source-id: 3d02084666fde532ec76134edf8cf6a231060a48
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f46cf2b0ce
commit
646b9d5a5d
@@ -14,7 +14,10 @@ import {
|
||||
_setGlobalInteractionReporter,
|
||||
_LoggerContext,
|
||||
} from 'flipper-plugin';
|
||||
import {createFlipperServer, FlipperServerState} from 'flipper-frontend-core';
|
||||
import {
|
||||
createFlipperServerWithSocket,
|
||||
FlipperServerState,
|
||||
} from 'flipper-frontend-core';
|
||||
import {
|
||||
FlipperServerImpl,
|
||||
getEnvironmentInfo,
|
||||
@@ -45,6 +48,8 @@ import {ElectronIpcClientRenderer} from './electronIpc';
|
||||
import {checkSocketInUse, makeSocketPath} from 'flipper-server-core';
|
||||
import {KeytarModule} from 'flipper-server-core/src/utils/keytar';
|
||||
import {initCompanionEnv} from 'flipper-server-companion';
|
||||
import ReconnectingWebSocket from 'reconnecting-websocket';
|
||||
import WS from 'ws';
|
||||
|
||||
enableMapSet();
|
||||
|
||||
@@ -70,10 +75,13 @@ async function getKeytarModule(staticPath: string): Promise<KeytarModule> {
|
||||
return keytar;
|
||||
}
|
||||
|
||||
async function getExternalServer() {
|
||||
const server = await createFlipperServer(
|
||||
'localhost',
|
||||
52342,
|
||||
async function getExternalServer(path: string) {
|
||||
const options = {
|
||||
WebSocket: WS,
|
||||
};
|
||||
const socket = new ReconnectingWebSocket(`ws+unix://${path}`, [], options);
|
||||
const server = await createFlipperServerWithSocket(
|
||||
socket,
|
||||
(_state: FlipperServerState) => {},
|
||||
);
|
||||
return server;
|
||||
@@ -105,7 +113,7 @@ async function getFlipperServer(
|
||||
|
||||
const getEmbeddedServer = async () => {
|
||||
if (serverRunning) {
|
||||
const server = await getExternalServer();
|
||||
const server = await getExternalServer(socketPath);
|
||||
await server.exec('shutdown').catch(() => {
|
||||
/** shutdown will ultimately make this request fail, ignore error. */
|
||||
});
|
||||
@@ -114,7 +122,6 @@ async function getFlipperServer(
|
||||
{
|
||||
environmentInfo,
|
||||
env: parseEnvironmentVariables(env),
|
||||
// TODO: make username parameterizable
|
||||
gatekeepers: gatekeepers,
|
||||
paths: {
|
||||
appPath,
|
||||
@@ -142,9 +149,10 @@ async function getFlipperServer(
|
||||
console.info('flipper-server: not running/listening, start');
|
||||
|
||||
const {readyForIncomingConnections} = await startServer({
|
||||
port: 52342,
|
||||
staticDir: staticPath,
|
||||
entry: 'index.web.dev.html',
|
||||
tcp: false,
|
||||
port: 52342,
|
||||
});
|
||||
|
||||
const server = await startFlipperServer(
|
||||
@@ -167,7 +175,7 @@ async function getFlipperServer(
|
||||
tailServerLogs(path.join(staticPath, loggerOutputFile));
|
||||
}
|
||||
|
||||
return getExternalServer();
|
||||
return getExternalServer(socketPath);
|
||||
}
|
||||
return getEmbeddedServer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user