diff options
author | Kierán Meinhardt <kmein@posteo.de> | 2024-10-11 15:22:46 +0200 |
---|---|---|
committer | Kierán Meinhardt <kmein@posteo.de> | 2024-10-11 15:37:09 +0200 |
commit | 1ac04f0fe598e5c16b6e7fe368320febd60be7a4 (patch) | |
tree | 4f92ec5b63fa86d06af40c9b59f63bc62fcbbdcc /backend/app/Main.hs | |
parent | 82a489dcfa5b6ac165fa01060d78ddb29a243d99 (diff) |
allow customization of backend port
Diffstat (limited to 'backend/app/Main.hs')
-rw-r--r-- | backend/app/Main.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/backend/app/Main.hs b/backend/app/Main.hs index a3d30c2..bec530e 100644 --- a/backend/app/Main.hs +++ b/backend/app/Main.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ApplicativeDo #-} module Main where import AutoTypes qualified as U @@ -39,6 +42,8 @@ args :: A.Parser Args args = Args <$> cmd' data Cmd = Serve + { serverPort :: Int + } cmd' :: A.Parser Cmd cmd' = @@ -48,7 +53,9 @@ cmd' = ] serveCmd :: A.Parser Cmd -serveCmd = pure Serve +serveCmd = do + serverPort <- A.option A.auto (A.metavar "PORT" <> A.showDefault <> A.value 8081 <> A.long "port" <> A.short 'p' <> A.help "The server port") + pure Serve {..} data Repo = Repo { commits :: [Commit] @@ -195,8 +202,8 @@ main = do repoT <- newEmptyTMVarIO _ <- forkIO do watch repoT root ref A.execParser (A.info (args <**> A.helper) A.idm) >>= \case - Args {cmd = Serve} -> do - W.runEnv 8081 $ \req respond -> do + Args {cmd = Serve {serverPort}} -> do + W.runEnv serverPort $ \req respond -> do case P.parseOnly R.parser (W.rawPathInfo req) of Right (R.SchemaJson path) -> do repo <- atomically (readTMVar repoT) |