breadboard-ai / breadboard

A library for prototyping generative AI applications.
Apache License 2.0
173 stars 23 forks source link

Connection Server doesn't always shut down gracefully #2031

Closed paullewis closed 2 months ago

paullewis commented 4 months ago

I've not been able to replicate consistently, but I've found a few times that port 5555 is left open and I have to manually stop the node process in the terminal. Wondering if there's something we can do to ensure that it stops and releases the port.

@aomarks, I think this might be a you thing, but lmk if not!

paullewis commented 4 months ago

Actually, on a related note if I try and have – say – the board-server package running alongside breadboard-web it fails because only one can have port 5555 open. Can we find a fresh port so I can run things alongside one another?

aomarks commented 3 months ago

Sorry, missed this issue! I noticed this a few times too, will take a look. I think the server is getting zombified sometimes. Automatic port selection is tricky because the main server needs to know the URL of it, which is currently hard-coded. I'll have it generate a command that will find and kill the zombie process too :)

aomarks commented 3 months ago

Here's a oneliner you can use in the meantime:

kill $(lsof -i tcp:5555 | tail -n 1 | head -n1 | cut -w -f2)
aomarks commented 2 months ago

@paullewis Hopefully this is fixed or at least improved. Make sure to npm ci to bring in the latest Wireit version, since I added a listener for SIGTERM that was missing, which I believe may have been the culprit in at least some cases here.

The connection server will also now print out the above oneliner in case it still happens.