Token read from invalid path
Summary: ^ Token is no longer in the static directory. Also, we can now use a shared utility. Reviewed By: aigoncharov Differential Revision: D46516296 fbshipit-source-id: c38d024061653ac8b3fb587c8e3ad83dba0b151d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7dc978c3d3
commit
132a20d5a7
@@ -22,6 +22,7 @@ import {initCompanionEnv} from 'flipper-server-companion';
|
|||||||
import {
|
import {
|
||||||
checkPortInUse,
|
checkPortInUse,
|
||||||
getEnvironmentInfo,
|
getEnvironmentInfo,
|
||||||
|
hasAuthToken,
|
||||||
startFlipperServer,
|
startFlipperServer,
|
||||||
startServer,
|
startServer,
|
||||||
} from 'flipper-server-core';
|
} from 'flipper-server-core';
|
||||||
@@ -132,16 +133,19 @@ async function connectToRunningServer(url: URL) {
|
|||||||
async function shutdown() {
|
async function shutdown() {
|
||||||
console.info('[flipper-server] Attempt to shutdown.');
|
console.info('[flipper-server] Attempt to shutdown.');
|
||||||
|
|
||||||
const tokenPath = path.resolve(staticPath, 'auth.token');
|
let token: string | undefined;
|
||||||
const token = await fs.readFile(tokenPath, 'utf-8');
|
if (await hasAuthToken()) {
|
||||||
|
token = await getAuthToken();
|
||||||
|
}
|
||||||
|
|
||||||
const searchParams = new URLSearchParams({token: token ?? ''});
|
const searchParams = new URLSearchParams(token ? {token} : {});
|
||||||
const url = new URL(`ws://localhost:${argv.port}?${searchParams}`);
|
const url = new URL(`ws://localhost:${argv.port}?${searchParams}`);
|
||||||
const server = await connectToRunningServer(url);
|
const server = await connectToRunningServer(url);
|
||||||
await server.exec('shutdown').catch(() => {
|
await server.exec('shutdown').catch(() => {
|
||||||
/** shutdown will ultimately make this request fail, ignore error. */
|
/** shutdown will ultimately make this request fail, ignore error. */
|
||||||
console.info('[flipper-server] Shutdown may have succeeded');
|
console.info('[flipper-server] Shutdown may have succeeded');
|
||||||
});
|
});
|
||||||
|
server.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
|
|||||||
Reference in New Issue
Block a user