Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use port manager #936

Merged
merged 10 commits into from
Nov 13, 2023
32 changes: 0 additions & 32 deletions packages/cli/lib/DevServerManager.js
Original file line number Diff line number Diff line change
@@ -8,11 +8,7 @@ const {
startPortManagerServer,
portManagerHasActiveServers,
stopPortManagerServer,
// getServerInstanceId,
} = require('@hubspot/local-dev-lib/portManager');
const {
assignPortToServerInstance,
} = require('../../../../hubspot-local-dev-lib/dist/lib/portManager');

const i18nKey = 'cli.lib.DevServerManager';

@@ -91,39 +87,11 @@ class DevServerManager {
if (this.initialized) {
await this.iterateDevServers(async serverInterface => {
if (serverInterface.start) {
const serverIds = serverInterface.getServerIds();

const ports = {};

for (let i = 0; i < serverIds.length; i++) {
const serverId = serverIds[i];

// For now, only support one instance of each server
// const instanceId = getServerInstanceId(
// serverId,
// projectConfig.name
// );
const instanceId = serverId;

try {
const port = await assignPortToServerInstance(instanceId);
ports[serverId] = port;
} catch (e) {
if (e.response.status === 409) {
throw new Error(
`Failed to start dev server with instanceId ${instanceId}. An instance of this server is already running.`
);
}
throw e;
}
}

await serverInterface.start({
accountId,
debug: this.debug,
httpClient,
projectConfig,
ports,
});
}
});