Skip to content

Commit

Permalink
feat(plugins): Allow to customise the plugin-host process
Browse files Browse the repository at this point in the history
Fixes #7180

Change-Id: I6977e799a74238637c50ed7e6845c610c208ec02
Signed-off-by: Florent Benoit <[email protected]>
  • Loading branch information
benoitf committed Feb 19, 2020
1 parent 00c1747 commit ef1f903
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import * as path from 'path';
import * as cp from 'child_process';
import { injectable, inject, named } from 'inversify';
import { ILogger, ConnectionErrorHandler, ContributionProvider, MessageService } from '@theia/core/lib/common';
Expand All @@ -33,9 +32,18 @@ export interface IPCConnectionOptions {
readonly errorHandler?: ConnectionErrorHandler;
}


export const HostedPluginProcessConfiguration = Symbol('HostedPluginProcessConfiguration');
export interface HostedPluginProcessConfiguration {
readonly path: string
}

@injectable()
export class HostedPluginProcess implements ServerPluginRunner {

@inject(HostedPluginProcessConfiguration)
protected configuration: HostedPluginProcessConfiguration;

@inject(ILogger)
protected readonly logger: ILogger;

Expand Down Expand Up @@ -166,7 +174,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
forkOptions.execArgv = ['--nolazy', `--inspect${inspectArg.substr(inspectArgPrefix.length)}`];
}

const childProcess = cp.fork(path.resolve(__dirname, 'plugin-host.js'), options.args, forkOptions);
const childProcess = cp.fork(this.configuration.path, options.args, forkOptions);
childProcess.stdout.on('data', data => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${data.toString().trim()}`));
childProcess.stderr.on('data', data => this.logger.error(`[${options.serverName}: ${childProcess.pid}] ${data.toString().trim()}`));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import * as path from 'path';
import { interfaces } from 'inversify';
import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
import { CliContribution } from '@theia/core/lib/node/cli';
Expand All @@ -26,7 +27,7 @@ import { HostedPluginSupport } from './hosted-plugin';
import { TheiaPluginScanner } from './scanners/scanner-theia';
import { HostedPluginServer, PluginScanner, HostedPluginClient, hostedServicePath, PluginDeployerHandler, PluginHostEnvironmentVariable } from '../../common/plugin-protocol';
import { GrammarsReader } from './scanners/grammars-reader';
import { HostedPluginProcess } from './hosted-plugin-process';
import { HostedPluginProcess, HostedPluginProcessConfiguration } from './hosted-plugin-process';
import { ExtPluginApiProvider } from '../../common/plugin-ext-api-contribution';
import { HostedPluginCliContribution } from './hosted-plugin-cli-contribution';
import { HostedPluginDeployerHandler } from './hosted-plugin-deployer-handler';
Expand Down Expand Up @@ -59,6 +60,7 @@ export function bindCommonHostedBackend(bind: interfaces.Bind): void {
bind(PluginDeployerHandler).toService(HostedPluginDeployerHandler);

bind(GrammarsReader).toSelf().inSingletonScope();
bind(HostedPluginProcessConfiguration).toConstantValue({ path: path.resolve(__dirname, 'plugin-host.js') });

bind(ConnectionContainerModule).toConstantValue(commonHostedConnectionModule);
}
Expand Down

0 comments on commit ef1f903

Please sign in to comment.