pub struct Upkeep { /* private fields */ }
Expand description

Block the calling thread until shutdown is requested.

Shutdown is requested when:

  • The process receives SIGINT.
  • A registered thread panics.
  • A required thread exists (optional threads are allowed to exit gracefully).

Shutdown Flow

  1. Request all registered threads to shutdown.
  2. Execute all on_shutdown callbacks. 3 Wait for all registered threads to exit.

Threads and handlers are iterated on in registration order.

Signal Handling

When a process is sent SIGINT the shutdown flow begins. The process is allowed to take as long as it wants to shutdown.

If a second SIGINT is received while the process is shutting down it will instead exit immediately.

Example

let mut up = Upkeep::new();
up.on_shutdown(|| println!("Bye :wave:"));
up.keepalive();

Implementations

Block the calling thread waiting for the process to shutdown.

Returns

This method returns true if the process shuts down cleanly.

Register a callback to be executed when a shutdown request is received.

Register signal handers for SIGINT and SIGTERM.

Register a Thread for shutdown.

Threads are politely asked to stop work and then joined. Threads MUST join for the process to exit correctly.

If a Thread registered with this function panics or exits the shutdown procedure for all other threads begins.

Similar to Upkeep::register_thread but clean exists do not shutdown the process.

Set the logger to be used by the Upkeep instance.

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more