diff options
-rw-r--r-- | Que/Server.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Que/Server.hs b/Que/Server.hs index 2b4e9f6..8eda6fb 100644 --- a/Que/Server.hs +++ b/Que/Server.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -54,20 +53,19 @@ import Network.Wai.Middleware.RequestLogger ( logStdout, ) import qualified System.Envy as Envy -import qualified System.Exit as Exit import qualified Web.Scotty.Trans as Scotty main :: IO () main = Exception.bracket startup shutdown <| uncurry Warp.run where - startup = Envy.decodeEnv >>= \case - Left e -> Exit.die e - Right c -> do - sync <- STM.newTVarIO initialAppState - let runActionToIO m = runReaderT (runApp m) sync - waiapp <- Scotty.scottyAppT runActionToIO routes - putText <| "port:" <> (show <| quePort c) - return (quePort c, waiapp) + startup = Envy.decodeWithDefaults Envy.defConfig >>= \c -> do + sync <- STM.newTVarIO initialAppState + let runActionToIO m = runReaderT (runApp m) sync + waiapp <- Scotty.scottyAppT runActionToIO routes + putText "*" + putText "que-server" + putText <| "port: " <> (show <| quePort c) + return (quePort c, waiapp) shutdown :: a -> IO a shutdown = pure . identity |