summaryrefslogtreecommitdiff
path: root/server/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/Main.hs')
-rw-r--r--server/Main.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/server/Main.hs b/server/Main.hs
index 60098b6..6806ee7 100644
--- a/server/Main.hs
+++ b/server/Main.hs
@@ -1,6 +1,9 @@
{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
@@ -39,7 +42,8 @@ import Servant (Application, Capture,
type (:>))
import Servant.HTML.Lucid (HTML)
import Servant.Server.StaticFiles (serveDirectoryWebApp)
-import Server (JobStatus, Org (..),
+import Server (CliOptions (..),
+ JobStatus, Org (..),
ServerState, Sha1,
emptyState, exneuland,
interval, loadConfig,
@@ -53,6 +57,8 @@ import Servant.API (Header)
import Servant.API.WebSocket (WebSocketPending)
import Servant.Client (ClientM, client,
mkClientEnv, runClientM)
+import Universum.Bool.Reexport (Bool)
+import WithCli (HasArguments, withCli)
type family PolyEndpoint method format payload where
PolyEndpoint Get format payload =
@@ -97,9 +103,11 @@ app queue = serve (Proxy @Routes) . server queue
postNewMaps :: Maybe Text -> MapService -> ClientM Text
postNewMaps = client (Proxy @(MapServiceAPI Post))
+
+
main :: IO ()
-main = do
- config <- loadConfig "./config.toml"
+main = withCli $ \CliOptions {..} -> do
+ config <- loadConfig (fromMaybe "./config.toml" config)
state <- newMVar (emptyState config)
queue :: TQueue Job <- newTQueueIO
loggerMiddleware <- mkRequestLogger
@@ -117,7 +125,7 @@ main = do
threadDelay (view interval config * 1000000)
-- TODO: what about tls / https?
- whenJust (view exneuland config) $ \baseurl -> do
+ unless offline $ whenJust (view exneuland config) $ \baseurl -> do
manager' <- newManager defaultManagerSettings
updater <- async $ runStdoutLoggingT $ forever $ do
done <- readMVar state
@@ -129,7 +137,7 @@ main = do
link updater
-- spawns threads for each job in the queue
- linter <- async $ void $ linterThread config queue state
+ linter <- async $ void $ linterThread offline config queue state
link linter
link poker