25 lines
830 B
Haskell
25 lines
830 B
Haskell
module Main where
|
|
|
|
import Control.Concurrent (forkIO, newMVar, newEmptyMVar)
|
|
import qualified Data.Map as Map
|
|
import PlausibleQuery (queryPageviewsLoop)
|
|
import Server (servePages)
|
|
import TemplateLoader (loadTemplates)
|
|
import TemplatePage (PageContext (PageContext, ctxPageviews))
|
|
import System.Environment (getArgs)
|
|
import qualified Config as C
|
|
|
|
main :: IO ()
|
|
main = do
|
|
(configFile:_) <- getArgs
|
|
config <- C.loadConfig configFile
|
|
let cServe = C.serve config
|
|
|
|
templates <- loadTemplates (C.baseUrl cServe) (C.templateDir cServe)
|
|
putStrLn $ "Found templates: " ++ show (map fst templates)
|
|
|
|
context <- newMVar $ PageContext {ctxPageviews = Map.empty}
|
|
updateNotify <- newEmptyMVar
|
|
|
|
_ <- forkIO $ queryPageviewsLoop config context updateNotify
|
|
servePages (C.port cServe) (Map.fromList templates) context updateNotify
|