2015-11-19 19:28:36 +01:00
|
|
|
-- | Main module for the blog's web server
|
2012-02-22 22:03:31 +01:00
|
|
|
module Main where
|
|
|
|
|
2019-08-23 13:03:17 +02:00
|
|
|
import Control.Applicative ((<$>), (<*>))
|
|
|
|
import Server (runBlog)
|
|
|
|
import System.Environment (getEnv)
|
2012-02-22 22:03:31 +01:00
|
|
|
|
2019-08-23 13:03:17 +02:00
|
|
|
data MainOptions
|
|
|
|
= MainOptions
|
|
|
|
{ blogPort :: Int,
|
|
|
|
resourceDir :: String
|
|
|
|
}
|
2014-03-11 18:12:51 +01:00
|
|
|
|
2019-08-23 13:03:17 +02:00
|
|
|
readOpts :: IO MainOptions
|
|
|
|
readOpts =
|
|
|
|
MainOptions
|
|
|
|
<$> (fmap read $ getEnv "PORT")
|
|
|
|
<*> getEnv "RESOURCE_DIR"
|
2015-11-19 19:28:36 +01:00
|
|
|
|
2019-08-23 13:03:17 +02:00
|
|
|
main :: IO ()
|
2012-03-09 17:57:53 +01:00
|
|
|
main = do
|
2019-08-23 13:03:17 +02:00
|
|
|
opts <- readOpts
|
2019-08-25 23:53:38 +02:00
|
|
|
putStrLn ("tazblog starting on port " ++ (show $ blogPort opts))
|
2019-08-23 13:03:17 +02:00
|
|
|
runBlog (blogPort opts) (resourceDir opts)
|