From 72b903812a3c2e032ab942a4f7775e7359cf9d72 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Fri, 6 Dec 2024 16:57:23 +0000 Subject: [PATCH] buffering --- src/Simplex/Chat/Mobile.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Chat/Mobile.hs b/src/Simplex/Chat/Mobile.hs index 887be07dee..90dbb3cb5a 100644 --- a/src/Simplex/Chat/Mobile.hs +++ b/src/Simplex/Chat/Mobile.hs @@ -54,7 +54,7 @@ import Simplex.Messaging.Encoding.String import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, sumTypeJSON) import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType (..), BasicAuth (..), CorrId (..), ProtoServerWithAuth (..), ProtocolServer (..)) import Simplex.Messaging.Util (catchAll, liftEitherWith, safeDecodeUtf8) -import System.IO (utf8) +import System.IO (BufferMode (..), hSetBuffering, stderr, stdout, utf8) import System.Timeout (timeout) data DBMigrationResult @@ -267,7 +267,10 @@ handleErr :: IO () -> IO String handleErr a = (a $> "") `catch` (pure . show @SomeException) chatSendCmd :: ChatController -> B.ByteString -> IO JSONByteString -chatSendCmd cc = withGlobalLogging logCfg . chatSendRemoteCmd cc Nothing +chatSendCmd cc cmd = withGlobalLogging logCfg $ do + hSetBuffering stdout LineBuffering + hSetBuffering stderr LineBuffering + chatSendRemoteCmd cc Nothing cmd chatSendRemoteCmd :: ChatController -> Maybe RemoteHostId -> B.ByteString -> IO JSONByteString chatSendRemoteCmd cc rh s = J.encode . APIResponse Nothing rh <$> runReaderT (execChatCommand rh s) cc