cloudflare / tableflip

Graceful process restarts in Go
BSD 3-Clause "New" or "Revised" License
2.91k stars 148 forks source link

Allow checking if Upgrader has a parent #24

Closed nolith closed 5 years ago

nolith commented 5 years ago

There are situations in which is useful to detect the first invocation, i.e. you may want to cleanup dangling unix sockets, but not during an upgrade.

Closes #23

lmb commented 5 years ago

Thank you for your contribution! Agree that HasParent makes sense.

Are you experiencing problems with dangling Unix sockets? The library should handle removing them if they are unused in the child.

nolith commented 5 years ago

Thanks @lmb, no I had no direct problem with the library.

What happened in my case is that the codebase I'm working on removes all the Unix sockets on boot before listening.

This is useful in case something went south on a previous run and you have the unix files left on disk.

With tableflip this approach will remove the unix socket during an upgrade and then even if upg.Fds.Listen("unix", path) returns a valid socket, you no longer have the file and clients can't connect.

As a first attempt I had to:

But I think you will agree that this adds a lot of complexity for no good reason

lmb commented 5 years ago

Sure thing! I was contemplating whether this should be exposed, but didn't have a good use case in mind.

Thanks again for contributing, and for writing tests as well!