Skip to content

Commit

Permalink
Fix restart instance on debug starts a regular instance
Browse files Browse the repository at this point in the history
Signed-off-by: Doron Nahari <[email protected]>
  • Loading branch information
DoroNahari authored and tolusha committed Sep 12, 2019
1 parent d0690be commit 4103e56
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/plugin-dev/src/browser/hosted-plugin-manager-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ export class HostedPluginManagerClient {
this.messageService.info('Starting hosted instance server ...');

if (debugConfig) {
this.isDebug = true;
this.pluginInstanceURL = await this.hostedPluginServer.runDebugHostedPluginInstance(this.pluginLocation.toString(), debugConfig);
} else {
this.isDebug = false;
this.pluginInstanceURL = await this.hostedPluginServer.runHostedPluginInstance(this.pluginLocation.toString());
}
await this.openPluginWindow();
Expand All @@ -170,9 +172,11 @@ export class HostedPluginManagerClient {
}

async debug(): Promise<void> {
this.isDebug = true;

await this.start({ debugMode: this.hostedPluginPreferences['hosted-plugin.debugMode'] });
await this.startDebugSessionManager();
}

async startDebugSessionManager(): Promise<void> {
let outFiles: string[] | undefined = undefined;
if (this.pluginLocation) {
const fsPath = await this.fileSystem.getFsPath(this.pluginLocation.toString());
Expand All @@ -194,11 +198,10 @@ export class HostedPluginManagerClient {
}

async stop(checkRunning: boolean = true): Promise<void> {
if (checkRunning && ! await this.hostedPluginServer.isHostedPluginInstanceRunning()) {
if (checkRunning && !await this.hostedPluginServer.isHostedPluginInstanceRunning()) {
this.messageService.warn('Hosted instance is not running.');
return;
}

try {
this.stateChanged.fire({ state: HostedInstanceState.STOPPING, pluginLocation: this.pluginLocation! });
await this.hostedPluginServer.terminateHostedPluginInstance();
Expand All @@ -221,10 +224,20 @@ export class HostedPluginManagerClient {
let lastError;
for (let tries = 0; tries < 15; tries++) {
try {
this.pluginInstanceURL = await this.hostedPluginServer.runHostedPluginInstance(this.pluginLocation!.toString());
if (this.isDebug) {
this.pluginInstanceURL = await this.hostedPluginServer.runDebugHostedPluginInstance(this.pluginLocation!.toString(), {
debugMode: this.hostedPluginPreferences['hosted-plugin.debugMode']
});
await this.startDebugSessionManager();
} else {
this.pluginInstanceURL = await this.hostedPluginServer.runHostedPluginInstance(this.pluginLocation!.toString());
}
await this.openPluginWindow();
this.messageService.info('Hosted instance is running at: ' + this.pluginInstanceURL);
this.stateChanged.fire({ state: HostedInstanceState.RUNNING, pluginLocation: this.pluginLocation! });
this.stateChanged.fire({
state: HostedInstanceState.RUNNING,
pluginLocation: this.pluginLocation!
});
return;
} catch (error) {
lastError = error;
Expand Down

0 comments on commit 4103e56

Please sign in to comment.