Automatically stopping processes started in a terminal, when SSH connections are cut
Hi,
I was asking AI about a little niggle I have with working with Coder. I start 3 dev processes (via three terminals) to develop my applications. 1 frontend app dev server. 1 backend app dev server. 1 monorepo command that starts watchers on a set of libraries.
If, for some reason, I leave my computer without shutting down everything, I might come back a day later, log back in, and am met with an error from my monorepo command that it is already running and in fact, all three processes are still running.
AI is saying I should run my own SSH server and Coder would know about it and use it, instead of its own. This way, I can control the config of the SSH server and do some changes to poll for the terminal client being alive and if not, close out the processes started by the terminal connections. This seems like a bit of hallu'ing to me, so before I go down this possible path of silliness, can anyone tell me:
Is AI right? Can I have my own SSH server and Coder's agent will know about it and use it?
If not, how would this little niggle of orphaned processes be solved other than just tearing down the container and restarting it all the time? Or, is that the actual answer? Why I don't do this now? Because, the container restart also tears down caching of my monorepo and my zsh history, which is both valuable for faster development.
Any insights would be greatly appreciated.
Any insights would be greatly appreciated.
4 Replies
<#1429368515319566476>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Hey, not exactly the solution that you are expecting, but maybe some terminal manager can solve your pain, like tmux or something, where you can rejoin a running process instead of stocking more on top
Thanks for the reply. I'll look into tmux.
So, I looked into tmux and it is, in effect, what Coder is doing already in terms of "sticky sessions" and isn't the solution. I also don't wish to add commands to developer workflow to enforce a "shutdown", as they can do this themselves, by closing their terminals.
No, what is happening is (and from my minimal understanding), when the Coder SSH connection is terminated by the local computer (shutting down or going into sleep mode), the closing of the SSH session doesn't send a SIGHUP signal to the processes that were started. These processes are then "orphaned". So, if the dev reconnects again, she will create new and additional processes. I just happened to run into this orphaning of processes, because Rush's CLI (Rush is my monorepo manager) notices when it is already running a process and fails to run it again. A WTF moment the first time it happened. 🙂
I'm thinking I might just need to create volumes for caching and terminal history and work with workspace scheduling. We should be doing this anyway or rather, will need work with scheduling at some time in the future.