Launch should be blocking and at a later stage
Summary: This should be a blocking call and done later as it depends on the FlipperServerConfig to be set. Reviewed By: antonk52 Differential Revision: D49193650 fbshipit-source-id: 4f74ca5de30b7f992880bbb9032792fd713203b7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dd6cef66f6
commit
3292945887
@@ -32,6 +32,7 @@ type ServerBootstrapPerformancePayload = {
|
|||||||
appServerStartedMS: number;
|
appServerStartedMS: number;
|
||||||
developmentServerAttachedMS: number;
|
developmentServerAttachedMS: number;
|
||||||
serverStartedMS: number;
|
serverStartedMS: number;
|
||||||
|
launchedMS: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type TrackerEvents = {
|
type TrackerEvents = {
|
||||||
|
|||||||
@@ -219,9 +219,6 @@ async function start() {
|
|||||||
`[flipper-server][bootstrap] HTTP server started (${httpServerStartedMS} ms)`,
|
`[flipper-server][bootstrap] HTTP server started (${httpServerStartedMS} ms)`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// At this point, the HTTP server is ready and listening.
|
|
||||||
launch();
|
|
||||||
|
|
||||||
const flipperServer = await startFlipperServer(
|
const flipperServer = await startFlipperServer(
|
||||||
rootPath,
|
rootPath,
|
||||||
staticPath,
|
staticPath,
|
||||||
@@ -238,14 +235,20 @@ async function start() {
|
|||||||
`[flipper-server][bootstrap] FlipperServer created (${serverCreatedMS} ms)`,
|
`[flipper-server][bootstrap] FlipperServer created (${serverCreatedMS} ms)`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// At this point, the HTTP server is ready and configuration is set.
|
||||||
|
await launch();
|
||||||
|
|
||||||
|
const t6 = performance.now();
|
||||||
|
const launchedMS = t6 - t5;
|
||||||
|
|
||||||
exitHook(async () => {
|
exitHook(async () => {
|
||||||
await flipperServer.close();
|
await flipperServer.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
const companionEnv = await initCompanionEnv(flipperServer);
|
const companionEnv = await initCompanionEnv(flipperServer);
|
||||||
|
|
||||||
const t6 = performance.now();
|
const t7 = performance.now();
|
||||||
const companionEnvironmentInitializedMS = t6 - t5;
|
const companionEnvironmentInitializedMS = t7 - t6;
|
||||||
|
|
||||||
console.info(
|
console.info(
|
||||||
`[flipper-server][bootstrap] Companion environment initialised (${companionEnvironmentInitializedMS} ms)`,
|
`[flipper-server][bootstrap] Companion environment initialised (${companionEnvironmentInitializedMS} ms)`,
|
||||||
@@ -263,8 +266,8 @@ async function start() {
|
|||||||
}
|
}
|
||||||
await flipperServer.connect();
|
await flipperServer.connect();
|
||||||
|
|
||||||
const t7 = performance.now();
|
const t8 = performance.now();
|
||||||
const appServerStartedMS = t7 - t6;
|
const appServerStartedMS = t8 - t7;
|
||||||
console.info(
|
console.info(
|
||||||
`[flipper-server][bootstrap] Ready for app connections (${appServerStartedMS} ms)`,
|
`[flipper-server][bootstrap] Ready for app connections (${appServerStartedMS} ms)`,
|
||||||
);
|
);
|
||||||
@@ -273,15 +276,15 @@ async function start() {
|
|||||||
await attachDevServer(app, server, socket, rootPath);
|
await attachDevServer(app, server, socket, rootPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
const t8 = performance.now();
|
const t9 = performance.now();
|
||||||
const developmentServerAttachedMS = t8 - t7;
|
const developmentServerAttachedMS = t9 - t8;
|
||||||
console.info(
|
console.info(
|
||||||
`[flipper-server][bootstrap] Development server attached (${developmentServerAttachedMS} ms)`,
|
`[flipper-server][bootstrap] Development server attached (${developmentServerAttachedMS} ms)`,
|
||||||
);
|
);
|
||||||
readyForIncomingConnections(flipperServer, companionEnv);
|
readyForIncomingConnections(flipperServer, companionEnv);
|
||||||
|
|
||||||
const t9 = performance.now();
|
const t10 = performance.now();
|
||||||
const serverStartedMS = t9 - t8;
|
const serverStartedMS = t10 - t9;
|
||||||
console.info(
|
console.info(
|
||||||
`[flipper-server][bootstrap] Listening at port ${chalk.green(
|
`[flipper-server][bootstrap] Listening at port ${chalk.green(
|
||||||
argv.port,
|
argv.port,
|
||||||
@@ -298,10 +301,12 @@ async function start() {
|
|||||||
appServerStartedMS,
|
appServerStartedMS,
|
||||||
developmentServerAttachedMS,
|
developmentServerAttachedMS,
|
||||||
serverStartedMS,
|
serverStartedMS,
|
||||||
|
launchedMS,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function launch() {
|
async function launch() {
|
||||||
|
console.info('[flipper-server] Launch UI');
|
||||||
const token = await getAuthToken();
|
const token = await getAuthToken();
|
||||||
|
|
||||||
const searchParams = new URLSearchParams({token: token ?? ''});
|
const searchParams = new URLSearchParams({token: token ?? ''});
|
||||||
|
|||||||
Reference in New Issue
Block a user