From 55c2994e856ceaf82edd06587e2faffb7c58950c Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 25 Feb 2022 16:30:45 +0100 Subject: server: write out adjusted maps --- server/Main.hs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'server/Main.hs') diff --git a/server/Main.hs b/server/Main.hs index d9c548b..cb1a65b 100644 --- a/server/Main.hs +++ b/server/Main.hs @@ -51,8 +51,10 @@ import Servant.Client (ClientM, client, mkClientEnv, runClientM) type family PolyEndpoint method format payload where - PolyEndpoint Get format payload = Get format payload - PolyEndpoint Post format payload = Header "Auth" Text :> ReqBody format payload :> Post '[PlainText] Text + PolyEndpoint Get format payload = + Get format payload + PolyEndpoint Post format payload = + Header "Auth" Text :> ReqBody format payload :> Post '[PlainText] Text type MapServiceAPI method = @@ -111,20 +113,21 @@ main = do threadDelay (view interval config * 1000000) -- TODO: what about tls / https? - manager' <- newManager defaultManagerSettings - -- updater <- async $ forever $ do - -- done <- readMVar state - -- res <- runClientM - -- (postNewMaps (view token config) (MapService done)) - -- (mkClientEnv manager' (view exneuland config)) - -- print res - -- threadDelay (view interval config * 1000000) + whenJust (view exneuland config) $ \baseurl -> do + manager' <- newManager defaultManagerSettings + updater <- async $ forever $ do + done <- readMVar state + res <- runClientM + (postNewMaps (view token config) (MapService done)) + (mkClientEnv manager' baseurl) + print res + threadDelay (view interval config * 1000000) + link updater -- spawns threads for each job in the queue linter <- async $ void $ linterThread config queue state link linter link poker - -- link updater let warpsettings = setPort (view port config) -- cgit v1.2.3