Closed Sebastiansch closed 7 years ago
@Sebastiansch nice! Thanks for your work on this. The one concern I have on first glance is that given a short port range. Say "8000-8005" and an attempt to launch more than five new services - the service would stall until a free port becomes available. I think there needs to be a new config entry which determines the number of port retries before a service exists with an error message.
Hi Carlos, yes, indeed this is also one of my concerns. Beside a config setting I see 2 other options:
What do you prefer? If a new config entry is the way to go, whats your preference for the key name?
I favor the first: Exit with error after all ports are tried, and there's no free port
How about servicePortRetries
or servicePortRetryCount
?
Also any though on supporting a group of ports such as:
{
"servicePort": "8000-8010, 8100, 8200-8205"
}
Might be overkill but a parser would simply create an array of ports in a range. Also it's important to document whether the range is inclusive or exclusive of the range specified.
There is now a promise reject, once ports are checked and all are blocked. Furthermore the servicePort config would now allow -as suggested by @cjus - multiple ports or port ranges in the format "8000-8010, 8100, 8200-8205".
As discussed, introduced a check if port is already used, when assigning a random service port Furthermore a fixed port range can be defined in config for random port assignment, for example "servicePort": "8080-8090"
Checking for ports is currently infinitely until a free port is found, so service won't start up until a free port is found.
Let me know your thoughts