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:
Lorenzo Blasa
2022-06-29 15:01:05 -07:00
committed by Facebook GitHub Bot
parent f46cf2b0ce
commit 646b9d5a5d
9 changed files with 110 additions and 35 deletions

View File

@@ -71,6 +71,11 @@ const argv = yargs
type: 'boolean',
default: false,
},
tcp: {
describe: 'Enable TCP connections on flipper-server.',
type: 'boolean',
default: true,
},
'rebuild-plugins': {
describe:
'Enables rebuilding of default plugins on Flipper build. Only make sense in conjunction with "--no-bundled-plugins". Enabled by default, but if disabled using "--no-plugin-rebuild", then plugins are just released as is without rebuilding. This can save some time if you know plugin bundles are already up-to-date.',
@@ -296,16 +301,28 @@ async function runPostBuildAction(archive: string, dir: string) {
// didn't change
console.log(`⚙️ Installing flipper-server.tgz using npx`);
await fs.remove(path.join(homedir(), '.npm', '_npx'));
await spawn('npx', [archive, argv.open ? '--open' : '--no-open'], {
stdio: 'inherit',
});
await spawn(
'npx',
[
archive,
argv.open ? '--open' : '--no-open',
argv.tcp ? '--tcp' : '--no-tcp',
],
{
stdio: 'inherit',
},
);
} else if (argv.start) {
console.log(`⚙️ Starting flipper-server from build dir`);
await yarnInstall(dir);
await spawn('./server.js', [argv.open ? '--open' : '--no-open'], {
cwd: dir,
stdio: 'inherit',
});
await spawn(
'./server.js',
[argv.open ? '--open' : '--no-open', argv.tcp ? '--tcp' : '--no-tcp'],
{
cwd: dir,
stdio: 'inherit',
},
);
}
}

View File

@@ -603,7 +603,11 @@ export function sleep(ms: number) {
let proc: child.ChildProcess | undefined;
export async function launchServer(startBundler: boolean, open: boolean) {
export async function launchServer(
startBundler: boolean,
open: boolean,
tcp: boolean,
) {
if (proc) {
console.log('⚙️ Killing old flipper-server...');
proc.kill(9);
@@ -617,6 +621,7 @@ export async function launchServer(startBundler: boolean, open: boolean) {
`../flipper-server/server.js`,
startBundler ? `--bundler` : `--no-bundler`,
open ? `--open` : `--no-open`,
tcp ? `--tcp` : `--no-tcp`,
],
{
cwd: serverDir,

View File

@@ -64,6 +64,11 @@ const argv = yargs
type: 'boolean',
default: true,
},
tcp: {
describe: 'Enable TCP connections on flipper-server.',
type: 'boolean',
default: true,
},
channel: {
description: 'Release channel for the build',
choices: ['stable', 'insiders'],
@@ -131,7 +136,7 @@ let startCount = 0;
async function restartServer() {
try {
await compileServerMain(true);
await launchServer(true, argv.open && ++startCount === 1); // only open on the first time
await launchServer(true, argv.open && ++startCount === 1, argv.tcp); // only open on the first time
} catch (e) {
console.error(
chalk.red(