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
Preferred port range? #24
Comments
Lil snippet that helps, in case you want to make this a feature: const getNumberRange = (start, end) => Array.from({length: (end - start)}, (v, k) => k + start);
(async () => {
const numberRange = getNumberRange(4000, 6000);
console.log(await getPort({port: numberRange}));
})(); |
I fail to see a use case where one would try to find an available port in a range of 1000+ ports, but I might be missing something. Anyhow, I think the array argument should do just fine for most scenarios. If you really need to target a specific range, you can provide it yourself just like in the example above. |
I agree. Accepting an array like we do now is sufficient enough. |
@tiagosiebler What's your use-case for needing ports in a specific range? |
@sindresorhus distributed nodejs workers, each of which may be running a long-term task. New task = new worker, so it's never sure how many I'll need on each server. Each worker exposes a dedicated REST API, but may not be running as a root user. I'm not sure if this lib might accidentally give a privileged port that requires root to open or how that kind of clash is handled. I'd rather just provide a larger range outside any normally used ports (30k->35k). The array generator above works fine for my needs, just thought I'd throw it out here in case you see value in adding it in as a feature. |
@acostalima we maintain a large number of components and sometimes need to work on several of them at the same time. Each component spins up a small local web server for it's demo (with all possible configurations). Since we will never go above say 200 components, it would be easy to declare a range from |
I don't want to overload the It should throw an error if the |
This can be really helpful when you try to find a useful port in a given range. A good example would be, Spotify [used to] listens on a specific port in range(say, from 6540 to 6550 something), the widget player in browser sends a request to I also found this feature required on a project of mine, where I tried to do the same thing as Spotify but settled for 3 ports in sequence, than 10 ports because I didn't want a ton of constants. Maybe useful 🤷♂️ |
@IssueHunt has funded $30.00 to this issue.
|
Fixes #24 Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@sindresorhus has rewarded $27.00 to @stroncium. See it on IssueHunt
|
Would be nice to see an option to provide a preferred range, rather than array of ports.
The text was updated successfully, but these errors were encountered: