Skip to content

Commit d0af815

Browse files
authored
Merge pull request #5421 from input-output-hk/coot/sighup-handlers
SIGHUP handlers
2 parents 6f393b7 + 2e0f3c0 commit d0af815

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

cardano-node/src/Cardano/Node/Run.hs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,20 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
438438
localRootsVar <- newTVarIO localRoots
439439
publicRootsVar <- newTVarIO publicRoots
440440
useLedgerVar <- newTVarIO (useLedgerAfterSlot nt)
441+
#ifdef UNIX
442+
-- initial `SIGHUP` handler, which only rereads the topology file but
443+
-- doesn't update block forging. The latter is only possible once
444+
-- consensus initialised (e.g. reapplied all blocks).
445+
_ <- Signals.installHandler
446+
Signals.sigHUP
447+
(Signals.Catch $ do
448+
updateTopologyConfiguration
449+
(startupTracer tracers) nc
450+
localRootsVar publicRootsVar useLedgerVar
451+
traceWith (startupTracer tracers) (BlockForgingUpdate NotEffective)
452+
)
453+
Nothing
454+
#endif
441455
void $
442456
let diffusionArgumentsExtra =
443457
mkP2PArguments nc
@@ -448,6 +462,7 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
448462
Node.run
449463
nodeArgs {
450464
rnNodeKernelHook = \registry nodeKernel -> do
465+
-- reinstall `SIGHUP` handler
451466
installP2PSigHUPHandler (startupTracer tracers) blockType nc nodeKernel
452467
localRootsVar publicRootsVar useLedgerVar
453468
rnNodeKernelHook nodeArgs registry nodeKernel
@@ -481,10 +496,23 @@ handleSimpleNode blockType runP p2pMode tracers nc onKernel = do
481496
| (NodeAddress (NodeHostIPAddress addr) port) <- ipProducerAddrs
482497
]
483498
(length ipProducerAddrs)
499+
#ifdef UNIX
500+
-- initial `SIGHUP` handler; it only warns that neither updating of
501+
-- topology is supported nor updating block forging is yet possible.
502+
-- It is still useful, without it the node would terminate when
503+
-- receiving `SIGHUP`.
504+
_ <- Signals.installHandler
505+
Signals.sigHUP
506+
(Signals.Catch $ do
507+
traceWith (startupTracer tracers) NetworkConfigUpdateUnsupported
508+
traceWith (startupTracer tracers) (BlockForgingUpdate NotEffective))
509+
Nothing
510+
#endif
484511
void $
485512
Node.run
486513
nodeArgs {
487514
rnNodeKernelHook = \registry nodeKernel -> do
515+
-- reinstall `SIGHUP` handler
488516
installNonP2PSigHUPHandler (startupTracer tracers) blockType nc nodeKernel
489517
rnNodeKernelHook nodeArgs registry nodeKernel
490518
}

cardano-node/src/Cardano/Node/Startup.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ data StartupTrace blk =
136136

137137
data EnabledBlockForging = EnabledBlockForging
138138
| DisabledBlockForging
139+
| NotEffective
140+
-- ^ one needs to send `SIGHUP` after consensus
141+
-- initialised itself (especially after replying all
142+
-- blocks).
139143
deriving (Eq, Show)
140144

141145
data BasicInfoCommon = BasicInfoCommon {

cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ ppStartupInfoTrace (BlockForgingUpdate b) =
493493
"Disabling block forging, to enable it please make the credentials "
494494
<> "files available again and then re-trigger reconfiguration via SIGHUP "
495495
<> "signal."
496+
NotEffective ->
497+
"Changing block forging is not effective until consensus has started. "
496498

497499
ppStartupInfoTrace (BlockForgingUpdateError err) =
498500
"Block forging reconfiguration error: "

0 commit comments

Comments
 (0)