Explicitly close ws in cases of a process exit

Summary:
^

There may be cases whereas the process exits but leaks the socket descriptors.

There's already a hook to close flipper-server.

Reviewed By: passy

Differential Revision: D37550940

fbshipit-source-id: 35004969834bb92bb7cf0f56bda8d7b43c11d6bf
This commit is contained in:
Lorenzo Blasa
2022-07-01 03:45:44 -07:00
committed by Facebook GitHub Bot
parent ae90ce5878
commit 583fdd9648

View File

@@ -18,6 +18,7 @@ import open from 'open';
import {initCompanionEnv} from 'flipper-server-companion'; import {initCompanionEnv} from 'flipper-server-companion';
import {startFlipperServer, startServer} from 'flipper-server-core'; import {startFlipperServer, startServer} from 'flipper-server-core';
import {isTest} from 'flipper-common'; import {isTest} from 'flipper-common';
import exitHook from 'exit-hook';
const argv = yargs const argv = yargs
.usage('yarn flipper-server [args]') .usage('yarn flipper-server [args]')
@@ -115,6 +116,10 @@ async function start() {
'external', 'external',
); );
exitHook(async () => {
await flipperServer.close();
});
enhanceLogger((logEntry) => { enhanceLogger((logEntry) => {
flipperServer.emit('server-log', logEntry); flipperServer.emit('server-log', logEntry);
}); });