diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index 6765a4d052f..4ea7726f95b 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -50,7 +50,8 @@ import Cardano.BM.Data.BackendKind (BackendKind (..)) import Cardano.BM.Data.LogItem (LOContent (..), PrivacyAnnotation (..), mkLOMeta) import Cardano.BM.Data.Tracer (ToLogObject (..), - TracingVerbosity (..)) + TracingVerbosity (..), TracingFormatting (..), + severityNotice, trTransformer) import Cardano.BM.Data.Transformers (setHostname) import Cardano.BM.Trace @@ -205,7 +206,7 @@ handleSimpleNode p trace nodeTracers npm onKernel = do Left err -> (putTextLn $ show err) >> exitFailure Right addr -> return addr - withShutdownHandler npm tracer $ + withShutdownHandler npm trace $ Node.run (consensusTracers nodeTracers) (protocolTracers nodeTracers) @@ -332,9 +333,9 @@ handleSimpleNode p trace nodeTracers npm onKernel = do -- either deliberatly by the parent process or automatically because the parent -- process itself terminated, then we initiate a clean shutdown. -- -withShutdownHandler :: NodeProtocolMode -> Tracer IO String -> IO () -> IO () +withShutdownHandler :: NodeProtocolMode -> Trace IO Text -> IO () -> IO () withShutdownHandler (RealProtocolMode NodeCLI{shutdownIPC = Just (Fd fd)}) - tracer action = + trace action = Async.race_ (wrapUninterruptableIO waitForEOF) action where waitForEOF :: IO () @@ -342,12 +343,17 @@ withShutdownHandler (RealProtocolMode NodeCLI{shutdownIPC = Just (Fd fd)}) hnd <- IO.fdToHandle fd r <- try $ IO.hGetChar hnd case r of - Left e | IO.isEOFError e -> traceWith tracer "received shutdown request" - | otherwise -> throwIO e + Left e + | IO.isEOFError e -> traceWith tracer "received shutdown request" + | otherwise -> throwIO e Right _ -> throwIO $ IO.userError "--shutdown-ipc FD does not expect input" + tracer :: Tracer IO Text + tracer = trTransformer TextualRepresentation MaximalVerbosity + (severityNotice trace) + withShutdownHandler _ _ action = action -- | Windows blocking file IO calls like 'hGetChar' are not interruptable by