hashicorp / go-plugin

Golang plugin system over RPC.
Mozilla Public License 2.0
5.25k stars 450 forks source link

Managed servers? #210

Open nicopernas opened 2 years ago

nicopernas commented 2 years ago

We've just started using this library and it's great. Thanks for developing and maintaining it.

One feature that we are missing though is managed servers. Right now, the (RPC) client is in charge of terminating the connection with the server once it's done using it. In our use case, we don't have a clear place where to make that call so we end up having multiple orphaned server processes lying around.

The way we solved it was to have the plugin (server) check for its parent process pid ever X seconds. When it detects a change we asume it is because the original parent (the RPC client) is gone (or we can check wether the parent pid is 1)

That works just fine. However, there's no easy way for us to clean up the socket files when we exit so they accumulate over time.

I was wondering about a feature where the server could be managed (just like the clients) where they do exactly what I mentioned above: if they detect their original parent process changes, it gracefully exits.

I'm happy to send a PR, just wanted to test the waters first. Thanks