From 6df27824b75f2024d4a8788ac11cba14355cdcf6 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 21 Sep 2023 06:09:19 -0700 Subject: [PATCH] Expose HTTP shutdown API Summary: Expose the shutdown API via the HTTP server. Reviewed By: ivanmisuno Differential Revision: D49496840 fbshipit-source-id: df2045edc89e9feabe74b4b513f973d137323d0f --- desktop/flipper-server-core/src/server/startServer.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/desktop/flipper-server-core/src/server/startServer.tsx b/desktop/flipper-server-core/src/server/startServer.tsx index b6213b3edbc..7d31f25cfb7 100644 --- a/desktop/flipper-server-core/src/server/startServer.tsx +++ b/desktop/flipper-server-core/src/server/startServer.tsx @@ -133,6 +133,14 @@ async function startHTTPServer(config: Config): Promise<{ res.end(JSON.stringify({isReady})); }); + app.get('/shutdown', (_req, res) => { + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify({success: true})); + + // Just exit the process, this will trigger the shutdown hooks. + process.exit(0); + }); + app.get('/health', (_req, res) => { res.end('flipper-ok'); });