buffering

This commit is contained in:
Evgeny Poberezkin
2024-12-06 16:57:23 +00:00
parent 9933ce3186
commit 72b903812a
+5 -2
View File
@@ -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