tvl-depot/services/tazblog/blog/Main.hs
Vincent Ambo be074c6085 refactor(tazblog): Move blog configuration to envvars
The port and resource directory are now specified via environment
variables and a wrapper script is created by Nix that sets the
resource path and so on correctly.
2019-08-23 12:03:17 +01:00

25 lines
556 B
Haskell

-- | Main module for the blog's web server
module Main where
import Control.Applicative ((<$>), (<*>))
import Locales (version)
import Server (runBlog)
import System.Environment (getEnv)
data MainOptions
= MainOptions
{ blogPort :: Int,
resourceDir :: String
}
readOpts :: IO MainOptions
readOpts =
MainOptions
<$> (fmap read $ getEnv "PORT")
<*> getEnv "RESOURCE_DIR"
main :: IO ()
main = do
putStrLn ("TazBlog " ++ version ++ " in Haskell starting")
opts <- readOpts
runBlog (blogPort opts) (resourceDir opts)