I’d like to determine from within a Linux (Ubuntu) server running on Fly whether a flyctl ssh console connection is currently active to the machine running that server. How can I do that?
I could use that information to avoid shutting the server down when idle (it is configured to stop after 2 minutes withouth active connections to the webapp it provides).
You could hack this together, but it’s not something that’s “officially” supported haha
If you list the network connections established for /.fly/hallpass, you should be able to tell if anyone is connected (this counts ssh as well as sftp).
For example, you can use lsof -ai -p $(pidof hallpass) | grep ESTABLISHED to list all active connections (if you have net-tools and grep installed).
I can’t guarantee that this will always work, but it should work for now. Do with that what you will
I currently run an RStudio Server[1] which I want to shut down immediately after the last active user quits their session. Thus I can’t directly rely on tired-proxy since it would mean a temporary internet connection loss would cause unsaved work to be lost. But I use it to be able to make the machine not reboot, i.e. I kill tired-proxy[2] when I want the machine to be stopped[3].
The deployed container uses the following ENTRYPOINT shell script:
When I try to terminate s6 via s6-svscanctl -t, the machine is stopped but immediately restarted. Thus I guess s6’ signals are not forwarded to flyd. ↩︎
The tired-proxy idle time is set higher than RStudio’s session-timeout-kill-hours setting, effectively rendering it ineffective. ↩︎