tvl-depot/blog/Main.hs

39 lines
1.1 KiB
Haskell
Raw Normal View History

2012-02-22 22:03:31 +01:00
module Main where
import Control.Applicative (pure, (<$>), (<*>))
import Control.Exception (bracket)
import Data.Acid
import Data.Acid.Local (createCheckpointAndClose)
import Options
2012-02-22 22:03:31 +01:00
import BlogDB (initialBlogState)
import Locales (version)
import Server
2012-02-22 22:03:31 +01:00
{- Server -}
2014-03-11 18:12:51 +01:00
data MainOptions = MainOptions {
optState :: String,
2014-03-11 18:22:59 +01:00
optPort :: Int,
optRes :: String
2014-03-11 18:12:51 +01:00
}
instance Options MainOptions where
defineOptions = pure MainOptions
<*> simpleOption "statedir" "/var/tazblog/"
"Directory in which the BlogState is located."
<*> simpleOption "port" 8000
"Port to run on. Default is 8000."
2014-03-11 18:22:59 +01:00
<*> simpleOption "res" "/usr/share/tazblog/res"
"Resources folder location."
main :: IO()
main = do
putStrLn ("TazBlog " ++ version ++ " in Haskell starting")
runCommand $ \opts args ->
bracket (openLocalStateFrom (optState opts ++ "BlogState") initialBlogState)
2013-04-28 14:44:14 +02:00
createCheckpointAndClose
(\acid -> runBlog acid (optPort opts) (optRes opts))
2012-03-06 00:50:53 +01:00
2012-03-13 06:35:56 +01:00