Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ShutdownFDs
- withShutdownHandling ∷ NodeConfiguration → Trace IO Text → (ShutdownFDs → IO ()) → IO ()
- data ShutdownDoorbell
- getShutdownDoorbell ∷ ShutdownFDs → Maybe ShutdownDoorbell
- triggerShutdown ∷ ShutdownDoorbell → Trace IO Text → Text → IO ()
- maybeSpawnOnSlotSyncedShutdownHandler ∷ NodeConfiguration → ShutdownFDs → Trace IO Text → ResourceRegistry IO → ChainDB IO blk → IO ()
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.
withShutdownHandling ∷ NodeConfiguration → Trace IO Text → (ShutdownFDs → IO ()) → 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.
getShutdownDoorbell ∷ ShutdownFDs → Maybe ShutdownDoorbell Source #
If ShutdownFDs
supports internal shutdown requests,
return its shutdown doorbell.
triggerShutdown ∷ ShutdownDoorbell → Trace IO Text → Text → IO () 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,
maybeSpawnOnSlotSyncedShutdownHandler ∷ NodeConfiguration → ShutdownFDs → Trace 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.