@@ -10,12 +10,12 @@ import Data.ByteString qualified as BS
10
10
import Hydra.Cluster.Fixture (KnownNetwork (.. ))
11
11
import Network.HTTP.Simple (getResponseBody , httpBS , parseRequest )
12
12
import System.IO.Error (isEOFError )
13
- import System.Process.Typed (createPipe , getStdout , proc , setStdout , withProcessWait_ )
13
+ import System.Process.Typed (createPipe , getStderr , proc , setStderr , withProcessWait_ )
14
14
15
15
data MithrilLog
16
16
= StartSnapshotDownload { network :: KnownNetwork , directory :: FilePath }
17
- | -- | Output captured directly from mithril-client
18
- StdOut { output :: Value }
17
+ | -- | Output captured directly from mithril-client stderr.
18
+ StdErr { output :: Value }
19
19
deriving stock (Eq , Show , Generic )
20
20
deriving anyclass (ToJSON , FromJSON )
21
21
@@ -28,7 +28,7 @@ downloadLatestSnapshotTo tracer network directory = do
28
28
traceWith tracer StartSnapshotDownload {network, directory}
29
29
genesisKey <- parseRequest genesisKeyURL >>= httpBS <&> getResponseBody
30
30
let cmd =
31
- setStdout createPipe $
31
+ setStderr createPipe $
32
32
proc " mithril-client" $
33
33
concat
34
34
[ [" --aggregator-endpoint" , aggregatorEndpoint]
@@ -37,15 +37,15 @@ downloadLatestSnapshotTo tracer network directory = do
37
37
, [" --download-dir" , directory]
38
38
, [" --json" ]
39
39
]
40
- withProcessWait_ cmd traceStdout
40
+ withProcessWait_ cmd traceStderr
41
41
_ -> error $ " Network " <> show network <> " not supported by mithril."
42
42
where
43
- traceStdout p =
43
+ traceStderr p =
44
44
ignoreEOFErrors . forever $ do
45
- bytes <- BS. hGetLine (getStdout p)
45
+ bytes <- BS. hGetLine (getStderr p)
46
46
case Aeson. eitherDecodeStrict bytes of
47
47
Left err -> error $ " failed to decode: \n " <> show bytes <> " \n error: " <> show err
48
- Right output -> traceWith tracer StdOut {output}
48
+ Right output -> traceWith tracer StdErr {output}
49
49
50
50
ignoreEOFErrors =
51
51
handleJust (guard . isEOFError) (const $ pure () )
0 commit comments