Skip to content

Commit

Permalink
Added error logging to SIGHUP feature
Browse files Browse the repository at this point in the history
Added success message to log in case the topology file is parsed with success

Added error message to log in case the topology file fails to parse when
SIGHUP is sent
  • Loading branch information
bolt12 authored and karknu committed Oct 18, 2021
1 parent f577173 commit c7e38a0
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions cardano-node/src/Cardano/Node/Run.hs
Expand Up @@ -245,6 +245,10 @@ handleSimpleNode scp runP trace nodeTracers nc onKernel = do

nt <- readTopologyFileOrError nc

traceNamedObject
(appendName "topology-file" trace)
(meta, LogMessage (Text.pack "Successfully read topology configuration file"))

let (localRoots, publicRoots) = producerAddresses nt

localRootsVar <- newTVarIO localRoots
Expand Down Expand Up @@ -361,24 +365,34 @@ handleSimpleNode scp runP trace nodeTracers nc onKernel = do
(appendName "signal-handler" trace)
(meta, LogMessage (Text.pack "SIGHUP signal received - Performing topology configuration update"))

nt <- readTopologyFileOrError nc

let (localRoots, publicRoots) = producerAddresses nt

atomically $ do
writeTVar localRootsVar localRoots
writeTVar publicRootsVar publicRoots
writeTVar useLedgerVar (useLedgerAfterSlot nt)

traceNamedObject
(appendName "local-roots" trace)
(meta, LogMessage . Text.pack . show $ localRoots)
traceNamedObject
(appendName "public-roots" trace)
(meta, LogMessage . Text.pack . show $ publicRoots)
traceNamedObject
(appendName "use-ledger-after-slot" trace)
(meta, LogMessage . Text.pack . show $ useLedgerAfterSlot nt)
result <- try $ readTopologyFileOrError nc

case result of
Left (FatalError err) ->
traceNamedObject
(appendName "topology-file" trace)
(meta, LogMessage (Text.pack "Error reading topology configuration file:" <> err))
Right nt -> do
traceNamedObject
(appendName "topology-file" trace)
(meta, LogMessage (Text.pack "Successfully read topology configuration file"))

let (localRoots, publicRoots) = producerAddresses nt

atomically $ do
writeTVar localRootsVar localRoots
writeTVar publicRootsVar publicRoots
writeTVar useLedgerVar (useLedgerAfterSlot nt)

traceNamedObject
(appendName "local-roots" trace)
(meta, LogMessage . Text.pack . show $ localRoots)
traceNamedObject
(appendName "public-roots" trace)
(meta, LogMessage . Text.pack . show $ publicRoots)
traceNamedObject
(appendName "use-ledger-after-slot" trace)
(meta, LogMessage . Text.pack . show $ useLedgerAfterSlot nt)

{-# ANN handleSimpleNode ("HLint: ignore Reduce duplication" :: Text) #-}
#endif
Expand Down

0 comments on commit c7e38a0

Please sign in to comment.