cardano-node-1.28.0
Safe HaskellNone
LanguageHaskell2010

Cardano.Node.Handlers.Shutdown

Synopsis

Generalised shutdown handling

data ShutdownFDs Source #

ShutdownFDs mediate the graceful shutdown requests, either external or internal to the process.

In the external mediation case, the parent process passes us the file descriptor number of the read end of a pipe, via the CLI with --shutdown-ipc FD. In the internal mediation case, we create our own pipe. In both cases we store the accessible ends in ShutdownFDs.

In either case, if the write end gets closed, either deliberately: - by internal call of triggerShutdown on ShutdownFDs, or - by parent process ..or automatically, because the parent process itself terminated, then we initiate a clean shutdown.

withShutdownHandlingNodeConfigurationTrace IO Text → (ShutdownFDsIO ()) → IO () Source #

We provide an optional cross-platform method to politely request shut down.

For the duration of action, we gracefully handle shutdown requests, external or internal, as requested by configuration in NodeCLI, while allocating corresponding ShutdownFDs, and providing them to the action.

Requesting shutdown

data ShutdownDoorbell Source #

FD used to send an EOF-based request for shutdown.

getShutdownDoorbellShutdownFDsMaybe ShutdownDoorbell Source #

If ShutdownFDs supports internal shutdown requests, return its shutdown doorbell.

triggerShutdownShutdownDoorbellTrace IO TextTextIO () Source #

Given the ShutdownDoorbell component of ShutdownFDs, and an explanation of the reason, request a graceful shutdown.

Watch ChainDB for passing a configured slot sync limit threshold,

maybeSpawnOnSlotSyncedShutdownHandlerNodeConfigurationShutdownFDsTrace IO Text → ResourceRegistry IO → ChainDB IO blk → IO () Source #

If configuration in NodeCLI and ShutdownFDs agree, spawn a thread that would cause node to shutdown upon ChainDB reaching the configuration-defined slot.