Skip to content

Commit

Permalink
Merge pull request #936 from HubSpot/use-port-manager
Browse files Browse the repository at this point in the history
Use port manager
  • Loading branch information
camden11 authored Nov 13, 2023
2 parents 57576a2 + a900bcf commit 49af4cf
Show file tree
Hide file tree
Showing 2 changed files with 970 additions and 300 deletions.
14 changes: 14 additions & 0 deletions packages/cli/lib/DevServerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ const { COMPONENT_TYPES } = require('./projectStructure');
const { i18n } = require('./lang');
const { promptUser } = require('./prompts/promptUtils');
const { DevModeInterface } = require('@hubspot/ui-extensions-dev-server');
const {
startPortManagerServer,
portManagerHasActiveServers,
stopPortManagerServer,
requestPorts,
} = require('@hubspot/local-dev-lib/portManager');

const i18nKey = 'cli.lib.DevServerManager';

Expand Down Expand Up @@ -61,6 +67,7 @@ class DevServerManager {
this.debug = debug;
this.componentsByType = this.arrangeComponentsByType(components);

await startPortManagerServer();
await this.iterateDevServers(
async (serverInterface, compatibleComponents) => {
if (serverInterface.setup) {
Expand All @@ -86,6 +93,7 @@ class DevServerManager {
debug: this.debug,
httpClient,
projectConfig,
requestPorts,
});
}
});
Expand Down Expand Up @@ -113,6 +121,12 @@ class DevServerManager {
await serverInterface.cleanup();
}
});

const hasActiveServers = await portManagerHasActiveServers();

if (!hasActiveServers) {
await stopPortManagerServer();
}
}
}
}
Expand Down
Loading

0 comments on commit 49af4cf

Please sign in to comment.