A server needs to provide several huge (consuming lots of RAM) tcp-based services. What I want to achieve is, that they are started on-demand (lazy), and stopped after either the connection is closed or runs into a timeout. The different services are identified by their ports. If there is another connection and the server is already running, it should be directly forwarded without spawning another instance.
I know that I can lazily start services using (x)inetd. But it seems there is no way to detect a timeout or shutdown the service if the connection is closed, right?
Do you have any hint how such a service startup behavior could be realized using Debian Jessie?