diff options
author | tv <tv@shackspace.de> | 2014-11-06 16:10:43 +0100 |
---|---|---|
committer | tv <tv@shackspace.de> | 2014-11-06 16:10:43 +0100 |
commit | 9b2bea53c6bc87be639964aaca87c09ab16df486 (patch) | |
tree | 5bd768ccc901a357fbbf77ab337b2015eb486646 /src/Main | |
parent | 781e26234dd1854c51895fa4fcc31f26f209c52f (diff) |
Flush log after each request.
Diffstat (limited to 'src/Main')
-rw-r--r-- | src/Main/Config.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Main/Config.hs b/src/Main/Config.hs index 9639faa..66f72ea 100644 --- a/src/Main/Config.hs +++ b/src/Main/Config.hs @@ -20,7 +20,11 @@ import Text.Read (readEither) data Config = Config { cgroupRoot :: FilePath + -- ^ Mount point of the cgroup root. , httpPort :: Port + -- ^ TCP port number for cgserver to bind to. + , flushLog :: Bool + -- ^ Whether to flush the logging buffer after each request. } deriving Show @@ -33,12 +37,14 @@ data Config = Config -- -- > cgroupRoot = "/sys/fs/cgroup" -- > httpPort = 8001 +-- > flushLog = True -- defaultConfig :: IO Config defaultConfig = Config <$> getEnv' Right "/sys/fs/cgroup" "cgroupRoot" <*> getEnv' readEither 8001 "httpPort" + <*> getEnv' readBool True "flushLog" -- | Takes a parse function, a default value, and a variable name. @@ -53,3 +59,11 @@ getEnv' pf def name = error $ "Main.Config.getEnv' " <> show name <> ": " <> err Right value -> value + + +-- | Read a JSON-style boolean ("true", "false"). +readBool :: String -> Either String Bool +readBool x = case x of + "true" -> Right True + "false" -> Right False + _ -> Left $ "not a bool: " <> x |