cli
cli copied to clipboard
CLI to detect used ports
Describe the proposal
When using dapr run
, the CLI should proactively detect the currently used ports and error out with a clear message. This should be true for every port the CLI will use: Dapr HTTP port, Dapr gRPC port, App port and metrics. This can reduce a lot of friction when getting started on Dapr or simply day to day troubleshooting. The App port should be checked ONLY if there is a command to be executed after dapr run --
since the app can be executed separately from the dapr run
invocation.
Release Note
RELEASE NOTE: ADDED validation for currently used ports prior to executing dapr run
If dapr run --
is executed, we can check that the app-port
is already in use (desired).
If there is a command provided, then we can ensure that the app-port
is not already in use!
The option that I see here is to do something similar to what the FreePort method does, make a connection to an incoming port and see if it is free or not and then close connection if it is free ... That though would increase the delay for run IMO ... WDYT?
This is partially already available ie checking if a port is already being used for HTTP, gRPC and metrics port ...
# Run
dapr run -H 3500
in two different shells, you will get the error
WARNING: no application command found.
❌ invalid configuration for HTTPPort. Port 3500 is not available
The only enhancement needed here is when dapr run
has an app command to run, then the app port must not be an existing app port and that should error out similar to what we see above.
@artursouza These checks are present already as far as I can see.
@artursouza These checks are present already as far as I can see.
Can we close this issue if that is the case please?