On dashboard startup, check if ports are in use before starting Kestrel
Is there an existing issue for this?
- [x] I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
If the dashboard is started while a previous instance is running the user sees an unfriendly error message that the port is already in use. This will cause the dashboard startup to fail.
Describe the solution you'd like
Two things:
- Poll if ports are in use. If they are then wait a short time (5 seconds?) and try again. Makes dashboard more resilient
- Throw a friendly error message to the user.
Additional context
No response
@davidfowl
Providing a more friendly error message when ports are in use is a good improvement and I think we should do it. What do you think about a small delay to wait if they're not available?
A better error is fine, I don't think the dashboard should do anything to restart itself though. Do that in the app host.
I agree on not restarting if there is an error during startup.
But what about:
for (var i = 0; i < 5; i++)
{
if (PortsAvailable())
{
return;
}
await Task.Delay(1000);
}
throw new Exception("Friendly error message that dashboard ports are in use here.");
Worth having a small wait on startup for ports to become available? Or just leave this out and have DCP retry restarting the dashboard if there is any error? I'm leaning towards leaving it all up to DCP but just want to double check.
I'd vote for robustness in depth, given this is a complex multiprocess system...