about summary refs log tree commit diff
path: root/services/tazblog/blog
diff options
context:
space:
mode:
Diffstat (limited to 'services/tazblog/blog')
-rw-r--r--services/tazblog/blog/Main.hs39
1 files changed, 18 insertions, 21 deletions
diff --git a/services/tazblog/blog/Main.hs b/services/tazblog/blog/Main.hs
index 246f1325e7fc..2842d1ee1b72 100644
--- a/services/tazblog/blog/Main.hs
+++ b/services/tazblog/blog/Main.hs
@@ -1,28 +1,25 @@
 -- | Main module for the blog's web server
 module Main where
 
-import           Control.Applicative (pure, (<*>))
-import           Control.Exception   (bracket)
-import           Data.Word           (Word16)
-import           Locales             (version)
-import           Network             (HostName, PortID (..))
-import           Options
-import           Server
+import Control.Applicative ((<$>), (<*>))
+import Locales (version)
+import Server (runBlog)
+import System.Environment (getEnv)
 
-data MainOptions = MainOptions {
-  blogPort    :: Int,
-  resourceDir :: String
-}
+data MainOptions
+  = MainOptions
+      { blogPort :: Int,
+        resourceDir :: String
+        }
 
-instance Options MainOptions where
-  defineOptions = pure MainOptions
-    <*> simpleOption "blogPort" 8000
-        "Port to serve the blog on. Default is 8000."
-    <*> simpleOption "resourceDir" "/opt/tazblog/static"
-        "Resources folder location."
+readOpts :: IO MainOptions
+readOpts =
+  MainOptions
+    <$> (fmap read $ getEnv "PORT")
+    <*> getEnv "RESOURCE_DIR"
 
-main :: IO()
+main :: IO ()
 main = do
-    putStrLn ("TazBlog " ++ version ++ " in Haskell starting")
-    runCommand $ \opts _ ->
-      runBlog (blogPort opts) (resourceDir opts)
+  putStrLn ("TazBlog " ++ version ++ " in Haskell starting")
+  opts <- readOpts
+  runBlog (blogPort opts) (resourceDir opts)