-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use port manager #936
Changes from 8 commits
d85b2a5
c55868a
58b8371
3a40552
8ba6a6e
25deb95
9e65c3b
ad16774
41fb70f
a900bcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
||
|
@@ -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) { | ||
|
@@ -86,6 +93,7 @@ class DevServerManager { | |
debug: this.debug, | ||
httpClient, | ||
projectConfig, | ||
requestPorts, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
stopPortManagerServer(); | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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