Adds some settings to check flipper-server state
Summary: There's one setting: to enable or disable flipper-server. However, I've added some current running state to it. If there's a better way of doing this, please do let me know. Reviewed By: aigoncharov Differential Revision: D37276670 fbshipit-source-id: f6c941cf0cfe55c267b9bcb9f799934fba1e28ef
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8c67b049ab
commit
335dec1a08
@@ -87,7 +87,11 @@ async function getFlipperServer(
|
|||||||
);
|
);
|
||||||
const keytar: KeytarModule = await getKeytarModule(staticPath);
|
const keytar: KeytarModule = await getKeytarModule(staticPath);
|
||||||
const gatekeepers = getGatekeepers(environmentInfo.os.unixname);
|
const gatekeepers = getGatekeepers(environmentInfo.os.unixname);
|
||||||
if (gatekeepers['flipper_desktop_use_server']) {
|
|
||||||
|
const serverUsageEnabled = gatekeepers['flipper_desktop_use_server'];
|
||||||
|
const settings = await loadSettings();
|
||||||
|
|
||||||
|
if (serverUsageEnabled && (!settings.server || settings.server.enabled)) {
|
||||||
const socketPath = await makeSocketPath();
|
const socketPath = await makeSocketPath();
|
||||||
if (!(await checkSocketInUse(socketPath))) {
|
if (!(await checkSocketInUse(socketPath))) {
|
||||||
console.info('flipper-server: not running/listening, start');
|
console.info('flipper-server: not running/listening, start');
|
||||||
@@ -104,6 +108,7 @@ async function getFlipperServer(
|
|||||||
'',
|
'',
|
||||||
false,
|
false,
|
||||||
keytar,
|
keytar,
|
||||||
|
'embedded',
|
||||||
);
|
);
|
||||||
|
|
||||||
const companionEnv = await initCompanionEnv(server);
|
const companionEnv = await initCompanionEnv(server);
|
||||||
@@ -113,6 +118,7 @@ async function getFlipperServer(
|
|||||||
} else {
|
} else {
|
||||||
console.info('flipper-server: already running');
|
console.info('flipper-server: already running');
|
||||||
const loggerOutputFile = 'flipper-server-log.out';
|
const loggerOutputFile = 'flipper-server-log.out';
|
||||||
|
|
||||||
tailServerLogs(path.join(staticPath, loggerOutputFile));
|
tailServerLogs(path.join(staticPath, loggerOutputFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +145,7 @@ async function getFlipperServer(
|
|||||||
},
|
},
|
||||||
launcherSettings: await loadLauncherSettings(),
|
launcherSettings: await loadLauncherSettings(),
|
||||||
processConfig: loadProcessConfig(env),
|
processConfig: loadProcessConfig(env),
|
||||||
settings: await loadSettings(),
|
settings,
|
||||||
validWebSocketOrigins:
|
validWebSocketOrigins:
|
||||||
constants.VALID_WEB_SOCKET_REQUEST_ORIGIN_PREFIXES,
|
constants.VALID_WEB_SOCKET_REQUEST_ORIGIN_PREFIXES,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import {
|
|||||||
// In the future, this file would deserve it's own package, as it doesn't really relate to plugins.
|
// In the future, this file would deserve it's own package, as it doesn't really relate to plugins.
|
||||||
// Since flipper-plugin however is currently shared among server, client and defines a lot of base types, leaving it here for now.
|
// Since flipper-plugin however is currently shared among server, client and defines a lot of base types, leaving it here for now.
|
||||||
|
|
||||||
|
export type FlipperServerType = 'embedded' | 'external';
|
||||||
|
|
||||||
export type FlipperServerState =
|
export type FlipperServerState =
|
||||||
| 'pending'
|
| 'pending'
|
||||||
| 'starting'
|
| 'starting'
|
||||||
@@ -454,6 +456,7 @@ export type FlipperServerConfig = {
|
|||||||
processConfig: ProcessConfig;
|
processConfig: ProcessConfig;
|
||||||
validWebSocketOrigins: string[];
|
validWebSocketOrigins: string[];
|
||||||
environmentInfo: EnvironmentInfo;
|
environmentInfo: EnvironmentInfo;
|
||||||
|
type?: FlipperServerType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface FlipperServer {
|
export interface FlipperServer {
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ export type Settings = {
|
|||||||
host?: string;
|
host?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
};
|
};
|
||||||
|
server?: {
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum ReleaseChannel {
|
export enum ReleaseChannel {
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {parseEnvironmentVariables, getLogger} from 'flipper-common';
|
import {
|
||||||
|
parseEnvironmentVariables,
|
||||||
|
getLogger,
|
||||||
|
FlipperServerType,
|
||||||
|
} from 'flipper-common';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import {KeytarModule} from '../utils/keytar';
|
import {KeytarModule} from '../utils/keytar';
|
||||||
@@ -34,6 +38,7 @@ export async function startFlipperServer(
|
|||||||
settingsString: string,
|
settingsString: string,
|
||||||
enableLauncherSettings: boolean,
|
enableLauncherSettings: boolean,
|
||||||
keytarModule: KeytarModule,
|
keytarModule: KeytarModule,
|
||||||
|
type: FlipperServerType,
|
||||||
): Promise<FlipperServerImpl> {
|
): Promise<FlipperServerImpl> {
|
||||||
const execPath = process.execPath;
|
const execPath = process.execPath;
|
||||||
const appPath = rootDir;
|
const appPath = rootDir;
|
||||||
@@ -68,6 +73,7 @@ export async function startFlipperServer(
|
|||||||
processConfig: loadProcessConfig(env),
|
processConfig: loadProcessConfig(env),
|
||||||
settings: await loadSettings(settingsString),
|
settings: await loadSettings(settingsString),
|
||||||
validWebSocketOrigins: ['localhost:', 'http://localhost:'],
|
validWebSocketOrigins: ['localhost:', 'http://localhost:'],
|
||||||
|
type,
|
||||||
},
|
},
|
||||||
getLogger(),
|
getLogger(),
|
||||||
keytarModule,
|
keytarModule,
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ function getDefaultSettings(): Settings {
|
|||||||
enablePluginMarketplace: false,
|
enablePluginMarketplace: false,
|
||||||
marketplaceURL: '',
|
marketplaceURL: '',
|
||||||
enablePluginMarketplaceAutoUpdate: true,
|
enablePluginMarketplaceAutoUpdate: true,
|
||||||
|
server: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ async function start() {
|
|||||||
argv.settingsString,
|
argv.settingsString,
|
||||||
argv.launcherSettings,
|
argv.launcherSettings,
|
||||||
keytar,
|
keytar,
|
||||||
|
'external',
|
||||||
);
|
);
|
||||||
const companionEnv = await initCompanionEnv(flipperServer);
|
const companionEnv = await initCompanionEnv(flipperServer);
|
||||||
if (argv.failFast) {
|
if (argv.failFast) {
|
||||||
|
|||||||
@@ -130,8 +130,14 @@ class SettingsSheet extends Component<Props, State> {
|
|||||||
enablePluginMarketplace,
|
enablePluginMarketplace,
|
||||||
enablePluginMarketplaceAutoUpdate,
|
enablePluginMarketplaceAutoUpdate,
|
||||||
marketplaceURL,
|
marketplaceURL,
|
||||||
|
server,
|
||||||
} = this.state.updatedSettings;
|
} = this.state.updatedSettings;
|
||||||
|
|
||||||
|
const serverUsageEnabled = getRenderHostInstance().GK(
|
||||||
|
'flipper_desktop_use_server',
|
||||||
|
);
|
||||||
|
const serverType = getRenderHostInstance().serverConfig.type;
|
||||||
|
|
||||||
const settingsPristine =
|
const settingsPristine =
|
||||||
isEqual(this.props.settings, this.state.updatedSettings) &&
|
isEqual(this.props.settings, this.state.updatedSettings) &&
|
||||||
isEqual(this.props.launcherSettings, this.state.updatedLauncherSettings);
|
isEqual(this.props.launcherSettings, this.state.updatedLauncherSettings);
|
||||||
@@ -381,6 +387,58 @@ class SettingsSheet extends Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
</ToggledSection>
|
</ToggledSection>
|
||||||
</NUX>
|
</NUX>
|
||||||
|
<ToggledSection
|
||||||
|
label="Server (Experimental)"
|
||||||
|
toggled={(serverUsageEnabled && (!server || server.enabled)) ?? false}
|
||||||
|
frozen={!serverUsageEnabled}
|
||||||
|
onChange={(v) => {
|
||||||
|
this.setState((prevState) => ({
|
||||||
|
updatedSettings: {
|
||||||
|
...prevState.updatedSettings,
|
||||||
|
server: {enabled: v},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}}>
|
||||||
|
{serverUsageEnabled ? (
|
||||||
|
<>
|
||||||
|
<ConfigText
|
||||||
|
content={
|
||||||
|
"For changes to take effect, click on 'Apply and Restart'"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{serverType ? (
|
||||||
|
<>
|
||||||
|
<ConfigText
|
||||||
|
content={`Flipper is currently using an '${serverType}' server.`}
|
||||||
|
/>
|
||||||
|
{serverType === 'external' ? (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
<span>
|
||||||
|
To stop the server, it may be necessary to kill the
|
||||||
|
process listening at port <b>52342</b>. See below:
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<code>
|
||||||
|
sudo lsof -i -P | grep LISTEN | grep <b>52342</b>
|
||||||
|
<br />
|
||||||
|
sudo kill <PID>
|
||||||
|
</code>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<ConfigText
|
||||||
|
content={'The usage of flipperd (server) is currently disabled.'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ToggledSection>
|
||||||
<Layout.Right center>
|
<Layout.Right center>
|
||||||
<span>Reset all new user tooltips</span>
|
<span>Reset all new user tooltips</span>
|
||||||
<ResetTooltips />
|
<ResetTooltips />
|
||||||
|
|||||||
Reference in New Issue
Block a user