rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
333 stars 12 forks source link

Log/Access OS-allocated TCP port #50

Closed bonsairobo closed 3 months ago

bonsairobo commented 6 months ago

I tried calling mist.port(0) and the service logs Listening on http://localhost:0 instead of providing the actual port allocated by the OS.

bonsairobo commented 6 months ago

Similarly, the after_start callback will not provide the correct port.

rawhat commented 6 months ago

Yeah I haven't set that up yet. Shouldn't be too bad, I can look into it.

rawhat commented 6 months ago

This one was way easier after the glisten work had been done. It's also gonna require a major version release, and also has to wait for me to release the major version of glisten.

I can't guarantee any specific time, but I think I'm reaching a decent critical mass of things to do these releases. So it should be soon! I'll leave this open until it's actually released.

rawhat commented 3 months ago

Okay, this should be out on master. There are start_http_server and start_https_server methods that return a Server type. That can be passed to mist.get_port. The normal logger that says Listening at ... will list an OS-assigned port if you provide 0. But you can also access it programmatically. I'll be releasing this soon.