# cloudflare/tableflip

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/cloudflare-tableflip).**

3,155 stars · 156 forks · Go · bsd-3-clause

## Links

- GitHub: https://github.com/cloudflare/tableflip
- awesome-repositories: https://awesome-repositories.com/repository/cloudflare-tableflip.md

## Topics

`go` `golang` `graceful-restarts`

## Description

Tableflip is a zero-downtime restart library and system utility designed to transfer network sockets and open file descriptors between process instances. It serves as a process lifecycle manager that coordinates the handoff of TCP, UDP, and Unix domain sockets from a parent process to a child process to maintain active sessions during service upgrades.

The tool facilitates seamless restarts by utilizing file-based process ID tracking and system signals to trigger the spawning of new process instances. It ensures continuous service availability by handing over network listeners and using readiness signaling to notify parent processes when a new instance is prepared to take over.

The library also manages the transition phase through graceful shutdown coordination, which includes draining existing connections and synchronizing process exits. This is supported by low-level primitives for managing file descriptor transitions and signal-driven lifecycle events.

## Tags

### Networking & Communication

- [Socket Handoffs](https://awesome-repositories.com/f/networking-communication/socket-handoffs.md) — Passes open TCP or UDP listeners from a parent process to a child process to maintain continuous service availability.
- [Zero-Downtime Socket Handovers](https://awesome-repositories.com/f/networking-communication/zero-downtime-socket-handovers.md) — Provides a mechanism to transfer listening TCP, UDP, and Unix domain sockets between processes to ensure continuous service availability during restarts. ([source](https://github.com/cloudflare/tableflip/blob/master/env_syscalls.go))
- [Listener Handoffs](https://awesome-repositories.com/f/networking-communication/network-listeners/listener-handoffs.md) — Hands over TCP, UDP, and Unix domain socket listeners to a child process to maintain connectivity. ([source](https://github.com/cloudflare/tableflip/blob/master/fds_test.go))
- [Descriptor Passing](https://awesome-repositories.com/f/networking-communication/persistent-network-connections/descriptor-passing.md) — Provides a mechanism for passing network sockets and open files between process instances to maintain active sessions.
- [Socket Transfer Utilities](https://awesome-repositories.com/f/networking-communication/tcp-and-unix-socket-listeners/socket-transfer-utilities.md) — Provides a system for handing over Unix domain sockets and network listeners between processes during service upgrades.

### Development Tools & Productivity

- [Process Lifecycle Managers](https://awesome-repositories.com/f/development-tools-productivity/process-lifecycle-managers.md) — Acts as a coordinator for graceful shutdowns and process synchronization using file-based tracking and system signals.

### DevOps & Infrastructure

- [Graceful Shutdowns](https://awesome-repositories.com/f/devops-infrastructure/graceful-shutdowns.md) — Ensures clean termination of services by allowing in-flight requests to complete before shutting down.
- [Zero-Downtime Upgrades](https://awesome-repositories.com/f/devops-infrastructure/zero-downtime-upgrades.md) — Updates application code without dropping active network connections by transferring file descriptors between processes.

### Operating Systems & Systems Programming

- [File Descriptor Restoration](https://awesome-repositories.com/f/operating-systems-systems-programming/file-descriptor-restoration.md) — Allows the transfer of open file descriptors from a parent process to a child process to maintain active connections. ([source](https://github.com/cloudflare/tableflip/blob/master/parent.go))
- [Process Handoff Synchronization](https://awesome-repositories.com/f/operating-systems-systems-programming/process-handoff-synchronization.md) — Coordinates process shutdown by waiting for the parent process to exit or acknowledge the resource transfer.
- [Process Lifecycle Management](https://awesome-repositories.com/f/operating-systems-systems-programming/process-lifecycle-management.md) — Coordinates the handoff and graceful shutdown of system processes during version upgrades or configuration changes.
- [Signal-Driven Process Spawning](https://awesome-repositories.com/f/operating-systems-systems-programming/process-signal-management/signal-driven-process-spawning.md) — Triggers the creation of a new process instance and resource transfer upon receiving specific system signals.
- [Upgrade Signaling](https://awesome-repositories.com/f/operating-systems-systems-programming/process-signal-management/upgrade-signaling.md) — Triggers a new process instance and transfer of file descriptors upon receiving a specific system signal. ([source](https://github.com/cloudflare/tableflip/blob/master/http_example_test.go))
- [Non-Blocking File Descriptor Transitions](https://awesome-repositories.com/f/operating-systems-systems-programming/non-blocking-file-descriptor-transitions.md) — Sets inherited file descriptors to non-blocking mode to prevent the child process from hanging during execution.
- [Process Shutdown Synchronization](https://awesome-repositories.com/f/operating-systems-systems-programming/process-shutdown-synchronization.md) — Synchronizes process shutdown by waiting for a parent process to exit or responding to system signals. ([source](https://github.com/cloudflare/tableflip/blob/master/upgrader.go))

### System Administration & Monitoring

- [Connection Draining](https://awesome-repositories.com/f/system-administration-monitoring/terminal-session-managers/graceful-session-draining/connection-draining.md) — Implements a mechanism to stop accepting new connections while allowing existing requests to complete before process exit.
- [PID-Based Process Tracking](https://awesome-repositories.com/f/system-administration-monitoring/pid-based-process-tracking.md) — Uses a persistent file to store the process ID for coordinating transitions between old and new versions.

### Software Engineering & Architecture

- [Readiness Notifiers](https://awesome-repositories.com/f/software-engineering-architecture/automatic-configuration/initial-boot-configurations/boot-health-checkers/readiness-notifiers.md) — Notifies a parent process that a new instance is ready to take over and clean up inherited descriptors. ([source](https://github.com/cloudflare/tableflip/blob/master/upgrader.go))
