From 4b3e7340e1cf573abaf64febaa87db1c0d824149 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 18 Apr 2020 18:47:56 -0700 Subject: Fallback to default config on startup --- Que/Server.hs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'Que/Server.hs') 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 -- cgit v1.2.3