myriad/src/Myriad.hs

28 lines
781 B
Haskell
Raw Normal View History

module Myriad
( runMyriadServer
) where
2019-07-23 07:40:45 +02:00
import Control.Monad.Logger (runStdoutLoggingT)
import Data.String.Conversions
2019-07-23 07:40:45 +02:00
import Network.Wai.Handler.Warp
2020-06-17 05:56:01 +02:00
import Optics
2020-06-17 04:37:38 +02:00
import Myriad.Core
import Myriad.Docker
import Myriad.Server
2020-06-17 04:02:12 +02:00
runMyriadServer :: FilePath -> FilePath -> IO ()
runMyriadServer configPath languagesDir = do
env <- initEnv configPath languagesDir
2020-06-17 04:42:29 +02:00
runMyriadT env $ do
buildAllImages
startCleanup
logInfo ["Finished Docker-related setup"]
2020-06-17 05:56:01 +02:00
let myriadPort = fromIntegral $ env ^. #config % #port
2020-06-17 06:29:25 +02:00
onReady = runStdoutLoggingT $ logInfo ["Server started on http://localhost:", cs $ show myriadPort]
2019-07-23 07:40:45 +02:00
settings = setPort myriadPort . setBeforeMainLoop onReady $ defaultSettings
runSettings settings $ app env