cli icon indicating copy to clipboard operation
cli copied to clipboard

[Feature Request] Error when a port is taken

Open lorensr opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe.

When I do temporal server start-dev --ui-port 3000 and 3000 is already taken, I see no indication in the output that that's the case.

Describe the solution you'd like

Output:

Error: port 3000 is taken. Select another port with the --ui-port option.

and exit. Or better yet, increment until we get an open port:

Port 3000 is taken. Using port 3001 instead.
🆙
Temporal Server is running at: localhost:7233
Web UI is running at: http://localhost:3001

Could do for Server port as well as UI port?

lorensr avatar May 18 '23 23:05 lorensr

Hey @lorensr, how you doing? Hope you're well :)

Can i get this one? Thanks!

lucasmls avatar Sep 24 '23 10:09 lucasmls

Sorry for the delay—that would be great, thanks!

lorensr avatar Oct 08 '23 19:10 lorensr

Just so we're all aligned. I plan to open the PR by this weekend. Sorry about the delay.

lucasmls avatar Oct 20 '23 15:10 lucasmls

Testing on the rewrite branch it appears the command errors if the UI port is taken, but not the server port.

➜  temporal git:(cli-rewrite) ✗ ./temporal server start-dev --ui-port 3000
time=2024-03-01T08:53:58.904 level=ERROR msg="Failed to start gRPC listener" error="listen tcp 127.0.0.1:7233: bind: address already in use" service=frontend address=127.0.0.1:7233
Temporal server is running at: localhost:7233
Web UI is running at: http://localhost:3000
Metrics available at: http://localhost:50598/metrics
➜  temporal git:(cli-rewrite) ✗ ./temporal server start-dev --ui-port 3000
time=2024-03-01T08:54:18.517 level=ERROR msg="Failed to start gRPC listener" error="listen tcp 127.0.0.1:7233: bind: address already in use" service=frontend address=127.0.0.1:7233
{"time":"2024-03-01T08:54:18.520478-08:00","level":"FATAL","prefix":"echo","file":"server.go","line":"149","message":"listen tcp 127.0.0.1:3000: bind: address already in use"}

Quinn-With-Two-Ns avatar Mar 01 '24 16:03 Quinn-With-Two-Ns

I wonder if we should report this to the server. Server start should fail if frontend can't bind IMO (though I know much of server start is not synchronous for the start call, but I would accept an OnFatalError callback).

cretz avatar Mar 01 '24 17:03 cretz

Looks like the server does fail (pre CLI rewrite and with make start-sqlite in the server repo):

{"level":"fatal","ts":"2024-03-01T09:08:15.259-0800","msg":"Failed to start gRPC listener","error":"listen tcp 127.0.0.1:7233: bind: address already in use","service":"frontend","address":"127.0.0.1:7233",...

[1]    74946 exit 1     temporal server start-dev

bergundy avatar Mar 01 '24 17:03 bergundy

Is this resolved by https://github.com/temporalio/cli/pull/564 @mjameswh ?

tlalfano avatar Jun 18 '24 14:06 tlalfano

Is this resolved by https://github.com/temporalio/cli/pull/564?

Indeed. All the following are with CLI 0.12.0.

Frontend port already in use:

time=2024-06-20T23:31:58.607 level=ERROR msg="can't set frontend port 7233: listen tcp 127.0.0.1:7233: bind: address already in use"

Frontend HTTP port already in use:

time=2024-06-20T23:34:23.198 level=ERROR msg="can't set frontend HTTP port 8080: listen tcp 127.0.0.1:8080 bind: address already in use"

Metrics port already in use:

time=2024-06-20T23:35:54.333 level=ERROR msg="can't set metrics port 9001: listen tcp 127.0.0.1:9001: bind: address already in use"

UI port already in use:

{"time":"2024-06-20T23:32:25.810999-04:00","level":"FATAL","prefix":"echo","file":"server.go","line":"150","message":"listen tcp 127.0.0.1:8233: bind: address already in use"}

Note the last one has a different printing format. I'll fix that. Let's leave this ticket open until then.

mjameswh avatar Jun 21 '24 03:06 mjameswh