From fbbb7934975784014146a918616a7cc8eced18ce Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 19 Aug 2022 06:41:38 -0700 Subject: [PATCH] Shutdown flipper-server on Flipper Desktop launch Summary: At launch, if flipper-server is running, send the shutdown message. Reviewed By: passy Differential Revision: D38861178 fbshipit-source-id: 4aab5f2b50938cb70a2dfae0d9056df337baecc3 --- desktop/app/src/init.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 9c7ad9c30..002ba5027 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -107,15 +107,20 @@ async function getFlipperServer( const settings = await loadSettings(); const socketPath = await makeSocketPath(); - const serverRunning = await checkSocketInUse(socketPath); + let serverRunning = await checkSocketInUse(socketPath); + + if (serverRunning) { + console.info( + 'flipper-server: currently running/listening, attempt to shutdown', + ); + const server = await getExternalServer(socketPath); + await server.exec('shutdown').catch(() => { + /** shutdown will ultimately make this request fail, ignore error. */ + }); + serverRunning = false; + } const getEmbeddedServer = async () => { - if (serverRunning) { - const server = await getExternalServer(socketPath); - await server.exec('shutdown').catch(() => { - /** shutdown will ultimately make this request fail, ignore error. */ - }); - } const server = new FlipperServerImpl( { environmentInfo,