Skip to content

Commit 1ce548b

Browse files
committed
fix(service): Ensure stdout is line-buffered.
It's common in Linux containers to log to stdout, so let's ensure it's line-buffered, as we can't guarantee what the GHC runtime will do by default.
1 parent 7e956c7 commit 1ce548b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

primer-service/exe-server/Main.hs

+10-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ import Primer.Server (
5757
)
5858
import StmContainers.Map qualified as StmMap
5959
import System.Environment (lookupEnv)
60+
import System.IO (
61+
BufferMode (LineBuffering),
62+
hSetBuffering,
63+
)
6064

6165
{- HLINT ignore GlobalOptions "Use newtype instead of data" -}
6266
data GlobalOptions = GlobalOptions
@@ -189,7 +193,12 @@ run opts = case cmd opts of
189193
runDb (Db.ServiceCfg dbOpQueue ver) db
190194

191195
main :: IO ()
192-
main = execParser opts >>= run
196+
main = do
197+
-- It's common in Linux containers to log to stdout, so let's ensure
198+
-- it's line-buffered, as we can't guarantee what the GHC runtime
199+
-- will do by default.
200+
hSetBuffering stdout LineBuffering
201+
execParser opts >>= run
193202
where
194203
opts =
195204
info

0 commit comments

Comments
 (0)