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
Merged

Use port manager #936

merged 10 commits into from
Nov 13, 2023

Conversation

camden11
Copy link
Contributor

@camden11 camden11 commented Sep 29, 2023

Description and Context

See https://git.hubteam.com/HubSpot/hubspot-cli-issues/issues/462

This sets up the DevServerManager in the CLI to fetch ports from the port manager for each dev server it needs to run. It then passes those ports to the respective dev servers (for now, just the UIE dev server). This is set up to only allow one hs project dev process but in the future, we could support more than one by appending component or project ids to server instance ids.

Related port manager PRs:
HubSpot/hubspot-local-dev-lib#42
https://git.hubteam.com/HubSpot/ui-extensibility/pull/1566

Todo

This PR adds a dependency on local-dev-lib, so will need to publish its first (non-prerelease) release. Local dev lib also currently uses a newer node version, so we'll either have to change that dep or see if we can upgrade node on the CLI

Who to Notify

@brandenrodgers @kemmerle

@camden11 camden11 marked this pull request as draft September 29, 2023 18:38
@camden11 camden11 changed the title WIP: Use port manager POC: Use port manager Oct 4, 2023
@camden11 camden11 marked this pull request as ready for review October 4, 2023 20:31
@@ -61,6 +70,7 @@ class DevServerManager {
this.debug = debug;
this.componentsByType = this.arrangeComponentsByType(components);

await startPortManagerServer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment here is relevant. It should enable you to catch port conflicts when attempting to start up the server manager and log a useful error here

@@ -86,6 +93,7 @@ class DevServerManager {
debug: this.debug,
httpClient,
projectConfig,
requestPorts,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker - I wonder if this is something that we should be passing down to the servers or if they should just import it directly from local-dev-lib. They will likely already have local-dev-lib as a dep anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought about this a bit. I ended up going with this approach because the CLI is responsible for starting the port manager server. So when the server gets it from the DevServerManager, it comes with a guarantee that the port manager is actually running. In practice though I don't think it would really make a difference, so not opposed to changing this.

@@ -113,6 +121,10 @@ class DevServerManager {
await serverInterface.cleanup();
}
});

if (!portManagerHasActiveServers()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

portManagerHasActiveServers is async so you'll need await here. The stop function is also async and we might want to wait for that so we can handle errors if there are any

@camden11 camden11 changed the title POC: Use port manager Use port manager Nov 8, 2023
@camden11 camden11 merged commit 49af4cf into master Nov 13, 2023
1 check passed
@camden11 camden11 deleted the use-port-manager branch November 13, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants