cloudflare / tableflip

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

Refactor the upgrader into a goroutine #20

Closed lmb closed 5 years ago

lmb commented 5 years ago

The upgrader has fairly complex logic and locking behaviour. The Stop() method is more involved than it should be, since we need to clean up if no upgrade happened.

Moving the code into a goroutine makes the flow and invariants easier to understand.

There is one semantic change: Upgrade() does not return an error if the parent unexpectedly writes to the shutdown pipe. The likelihood of this happening is low, and it's not clear how severe that problem would be. By not rejecting upgrade requests we allow users to fix such problems without having to do a full restart.