diff options
author | Ben Sima <ben@bsima.me> | 2020-04-18 18:47:56 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-04-18 18:47:56 -0700 |
commit | 4b3e7340e1cf573abaf64febaa87db1c0d824149 (patch) | |
tree | 6c4d76aaddd06f458d70d63ac2e1131c3931e4b3 | |
parent | ccf98e9587359fcdba8317c9674b382488564f2f (diff) |
Fallback to default config on startup
-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 |