2012-02-22 22:03:31 +01:00
|
|
|
module Main where
|
|
|
|
|
2014-05-18 22:39:38 +02:00
|
|
|
import Control.Applicative (pure, (<$>), (<*>))
|
2013-04-28 14:30:00 +02:00
|
|
|
import Control.Exception (bracket)
|
2012-03-07 17:31:42 +01:00
|
|
|
import Data.Acid
|
2014-05-18 22:39:38 +02:00
|
|
|
import Data.Acid.Local (createCheckpointAndClose)
|
2012-03-25 19:29:38 +02:00
|
|
|
import Options
|
2012-02-22 22:03:31 +01:00
|
|
|
|
2014-05-18 22:39:38 +02:00
|
|
|
import BlogDB (initialBlogState)
|
|
|
|
import Locales (version)
|
|
|
|
import Server
|
2012-02-22 22:03:31 +01:00
|
|
|
|
2012-03-09 17:57:53 +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."
|
|
|
|
|
2012-03-09 17:57:53 +01:00
|
|
|
main :: IO()
|
|
|
|
main = do
|
|
|
|
putStrLn ("TazBlog " ++ version ++ " in Haskell starting")
|
2012-03-25 19:29:38 +02:00
|
|
|
runCommand $ \opts args ->
|
|
|
|
bracket (openLocalStateFrom (optState opts ++ "BlogState") initialBlogState)
|
2013-04-28 14:44:14 +02:00
|
|
|
createCheckpointAndClose
|
2014-05-18 22:39:38 +02:00
|
|
|
(\acid -> runBlog acid (optPort opts) (optRes opts))
|
2012-03-06 00:50:53 +01:00
|
|
|
|
2012-03-13 06:35:56 +01:00
|
|
|
|