diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 9c2e974c8..80d697ad7 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -154,11 +154,14 @@ async function getFlipperServer( console.info('[flipper-server] Not running/listening, start'); - const {readyForIncomingConnections} = await startServer({ - staticPath, - entry: 'index.web.dev.html', - port, - }); + const {readyForIncomingConnections} = await startServer( + { + staticPath, + entry: 'index.web.dev.html', + port, + }, + environmentInfo, + ); const server = await startFlipperServer( appPath, diff --git a/desktop/flipper-server-core/src/server/startServer.tsx b/desktop/flipper-server-core/src/server/startServer.tsx index d43c26c3a..3277ef440 100644 --- a/desktop/flipper-server-core/src/server/startServer.tsx +++ b/desktop/flipper-server-core/src/server/startServer.tsx @@ -20,6 +20,7 @@ import {FlipperServerImpl} from '../FlipperServerImpl'; import {FlipperServerCompanionEnv} from 'flipper-server-companion'; import {validateAuthToken} from '../app-connectivity/certificate-exchange/certificate-utils'; import {tracker} from '../tracker'; +import {EnvironmentInfo} from 'flipper-common'; type Config = { port: number; @@ -89,13 +90,16 @@ let isReadyWaitable: Promise | undefined; * @param config Server configuration. * @returns Returns a promise to the created server, proxy and WS server. */ -export async function startServer(config: Config): Promise<{ +export async function startServer( + config: Config, + environmentInfo: EnvironmentInfo, +): Promise<{ app: Express; server: http.Server; socket: WebSocketServer; readyForIncomingConnections: ReadyForConnections; }> { - return await startHTTPServer(config); + return await startHTTPServer(config, environmentInfo); } /** @@ -104,7 +108,10 @@ export async function startServer(config: Config): Promise<{ * @param config Server configuration. * @returns A promise to both app and HTTP server. */ -async function startHTTPServer(config: Config): Promise<{ +async function startHTTPServer( + config: Config, + environmentInfo: EnvironmentInfo, +): Promise<{ app: Express; server: http.Server; socket: WebSocketServer; @@ -133,6 +140,11 @@ async function startHTTPServer(config: Config): Promise<{ res.end(JSON.stringify({isReady})); }); + app.get('/info', (_req, res) => { + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(environmentInfo)); + }); + app.get('/shutdown', (_req, res) => { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({success: true})); diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 6a58f4db1..b4aac56f4 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -175,11 +175,14 @@ async function start() { `[flipper-server][bootstrap] Check for running instances completed (${runningInstanceShutdownMS} ms)`, ); - const {app, server, socket, readyForIncomingConnections} = await startServer({ - staticPath, - entry: `index.web${argv.bundler ? '.dev' : ''}.html`, - port: argv.port, - }); + const {app, server, socket, readyForIncomingConnections} = await startServer( + { + staticPath, + entry: `index.web${argv.bundler ? '.dev' : ''}.html`, + port: argv.port, + }, + environmentInfo, + ); const t4 = performance.now(); const httpServerStartedMS = t4 - t3;