5 stable releases

new 2.1.2 Mar 24, 2025
2.1.1 Oct 9, 2024
2.1.0 Dec 4, 2023
2.0.0 Apr 28, 2023
1.0.0 Apr 4, 2023

#154 in Unix APIs

Download history 4267/week @ 2024-12-02 4519/week @ 2024-12-09 3676/week @ 2024-12-16 958/week @ 2024-12-23 2317/week @ 2024-12-30 4302/week @ 2025-01-06 4190/week @ 2025-01-13 5015/week @ 2025-01-20 5827/week @ 2025-01-27 5636/week @ 2025-02-03 5486/week @ 2025-02-10 5298/week @ 2025-02-17 5519/week @ 2025-02-24 6538/week @ 2025-03-03 8086/week @ 2025-03-10 6386/week @ 2025-03-17

26,585 downloads per month

BSD-3-Clause

38KB
661 lines

shellflip

crates.io docs.rs

Graceful process restarts in Rust.

This crate facilitates upgrading or reconfiguring a service without disrupting existing connections. This is achieved by forking the process and communicating a small amount of state between the old and new processes; once the new process has started successfully the old process may terminate.

This crate has the following goals:

  • No old code keeps running after a successful upgrade (and inevitable shutdown of the old process)
  • The new process has a grace period for performing initialisation
  • Crashing during initialisation is OK
  • Only a single upgrade is ever run in parallel
  • It is possible for the user/process initiating the upgrade to know if the upgrade succeeded

Inspired by the tableflip go package but not a direct replacement.

Using the library

A full example is given in the restarter example service.

The main struct of interest is RestartConfig which has methods for detecting or initiating restart. For shutting down a restarted process, the ShutdownCoordinator provides the means for both signalling a shutdown event to spawned tasks, and awaiting their completion.

License

BSD licensed. See the LICENSE file for details.

🦀ノ( º _ ºノ) - respect crables!

Dependencies

~6–16MB
~200K SLoC