-
Notifications
You must be signed in to change notification settings - Fork 333
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
Change node default port #739
Conversation
@wqsz7xn I didn't notice that you have added strictOptions to subql-node. I have a concern that this might break something from hosted service, because with this option, they have to handle the args in different subql version in a precious manner now. |
@ianhe8x @zhex |
I think both changes will affect hosted service. all the existing deployments in the hosted service are running on the default port, which means we need to force set a port after this version is released. The hosted service need to support different versions in one template, |
|
@wqsz7xn how about instead of change the port to 3001, we leave it 3000 unchanged but detect when there's port conflict, we increase 1 until finding an available port. |
Now that I think about it this is a bit weird and would mean that ports are different across environments, also weird that we are port scanning on one service but not the other (we could do both). How about we just use some other unbound port? We have a envvar in place if people want to change the port themselves. I might be missing some advantage to port scanning though |
create-react-app use this approach. https://github.com/facebook/create-react-app/blob/f0a837c1f07ebd963ddbba2c2937d04fc1b79d40/packages/react-dev-utils/WebpackDevServerUtils.js This will only be used when no port is specified via env or args. |
We have decided against doing it the createreactapp way because we don't really want user input here and will do a few tries against an iterated port. They can set their own port if they really want it |
packages/common/src/project/utils.ts
Outdated
} | ||
}) | ||
.catch((err) => { | ||
console.error(err); |
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.
clean up console.error, or print only when --debug is used.
@@ -84,6 +86,10 @@ export class GraphqlModule implements OnModuleInit, OnModuleDestroy { | |||
cors: true, | |||
}); | |||
|
|||
if (this.config.get('playground')) { | |||
logger.info('Started playground at http://localhost:3000'); |
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.
Print the actual used port.
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.
oh yeah
packages/common/src/project/utils.ts
Outdated
|
||
export async function findAvailablePort(startPort: number, range = 10): Promise<number> { | ||
for (let port = startPort; port <= startPort + range; port++) { | ||
const _port = await detectPort(port).catch(() => { |
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.
const _port = await detectPort(port).catch(() => { | |
try{ | |
const _port = await detectPort(port) | |
... | |
} catch(e) { | |
return null; | |
} |
just code styling
* change node default port * remove strictOptions from node and query and add fallback port to query * add port scan * more tests and change promise * add sanitization to arguments * code style
3001
and keeps the default port of the query service as3000
getYargsOptions
so that invalid flags are not swallowed