A Go library for managing application shutdown with graceful cleanup of resources using OS signals.
Death is a Go library designed to manage application shutdown gracefully by handling OS signals and coordinating the cleanup of resources. It solves the problem of ensuring that files, network connections, and other resources are properly closed when an application receives termination signals like SIGINT or SIGTERM.
Go developers building long-running applications, servers, or daemons that need reliable shutdown procedures and resource cleanup.
Developers choose Death for its simplicity, minimal dependencies, and flexibility—it works with any logger, supports custom cleanup functions, and provides clear error handling without complicating the codebase.
Managing go application shutdown with signals.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Death follows a minimalist philosophy with no heavy dependencies, making it easy to integrate without bloating projects, as emphasized in the README's design goals.
It supports both standard io.Closer objects and anonymous functions via WaitForDeathWithFunc, allowing versatile cleanup logic as shown in the code examples.
Errors from failed closers are returned, enabling developers to log issues or manage exit codes, which is highlighted in the error handling feature description.
Version 3+ is compatible with various logging libraries by implementing the deathlog.Logger interface, providing flexibility without locking into a specific logger, as noted in the version table.
Death lacks support for timeouts on cleanup operations, which could cause applications to hang indefinitely if a resource fails to close, a common gap in graceful shutdown scenarios.
With three major versions (v1, v2, v3) each supporting different logger interfaces, users must navigate compatibility issues, adding complexity to adoption and maintenance.
Resources must implement the io.Closer interface or be wrapped, which can be cumbersome for third-party libraries or complex objects without a Close method, restricting out-of-the-box use.