File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
cardano-testnet/src/Testnet Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do
127127
128128 let nodeStdoutFile = logDir </> node </> " stdout.log"
129129 nodeStderrFile = logDir </> node </> " stderr.log"
130+ nodePidFile = logDir </> node </> " node.pid"
130131 socketRelPath = socketDir </> node </> " sock"
131132 sprocket = Sprocket tempBaseAbsPath socketRelPath
132133
@@ -167,9 +168,12 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do
167168 -- We force the evaluation of initiateProcess so we can be sure that
168169 -- the process has started. This allows us to read stderr in order
169170 -- to fail early on errors generated from the cardano-node binary.
170- _ <- liftIO (IO. getPid hProcess)
171+ pid <- liftIO (IO. getPid hProcess)
171172 >>= hoistMaybe (NodeExecutableError $ " startNode:" <+> pretty node <+> " 's process did not start." )
172173
174+ -- We then log the pid in the temp dir structure.
175+ liftIO $ IO. writeFile nodePidFile $ show pid
176+
173177 -- Wait for socket to be created
174178 eSprocketError <-
175179 H. evalIO $
Original file line number Diff line number Diff line change @@ -124,7 +124,8 @@ cardanoTestnetDefault testnetOptions genesisOptions conf = do
124124-- > │ └── README.md
125125-- > ├── logs
126126-- > │ ├── node{1,2,3}
127- -- > │ │ └── {stderr,stdout}.log
127+ -- > │ │ ├── node.pid
128+ -- > | | └── {stderr,stdout}.log
128129-- > │ ├── ledger-epoch-state-diffs.log
129130-- > │ ├── ledger-epoch-state.log
130131-- > │ ├── node-20241010121635.log
@@ -305,7 +306,6 @@ cardanoTestnet
305306 <> spoNodeCliArgs
306307 <> maybe [] extraCliArgs nodeOptions
307308 pure $ eRuntime <&> \ rt -> rt{poolKeys= mKeys}
308- -- TODO log the node's pid in a file. This is useful for killing the node later.
309309
310310 let (failedNodes, testnetNodes') = partitionEithers eTestnetNodes
311311 unless (null failedNodes) $ do
You can’t perform that action at this time.
0 commit comments