yesod devel does not have a hard-coded port
This commit is contained in:
parent
56a5b167a6
commit
d535720a0b
@ -83,7 +83,7 @@ devel cabalCmd = do
|
|||||||
, concat
|
, concat
|
||||||
[ "import \""
|
[ "import \""
|
||||||
, pi'
|
, pi'
|
||||||
, "\" Handler (withDevelApp)"
|
, "\" Handler (withDevelAppPort)"
|
||||||
]
|
]
|
||||||
, "import Data.Dynamic (fromDynamic)"
|
, "import Data.Dynamic (fromDynamic)"
|
||||||
, "import Network.Wai.Handler.Warp (run)"
|
, "import Network.Wai.Handler.Warp (run)"
|
||||||
@ -96,7 +96,8 @@ devel cabalCmd = do
|
|||||||
, "main :: IO ()"
|
, "main :: IO ()"
|
||||||
, "main = do"
|
, "main = do"
|
||||||
, " putStrLn \"Starting app\""
|
, " putStrLn \"Starting app\""
|
||||||
, " forkIO $ (fromJust $ fromDynamic withDevelApp) $ run 3000"
|
, " wdap <- return $ fromJust $ fromDynamic withDevelAppPort"
|
||||||
|
, " forkIO $ wdap $ \\(port, app) -> run port app"
|
||||||
, " loop"
|
, " loop"
|
||||||
, ""
|
, ""
|
||||||
, "loop :: IO ()"
|
, "loop :: IO ()"
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
module Handler
|
module Handler
|
||||||
( with~sitearg~
|
( with~sitearg~
|
||||||
, withDevelApp
|
, withDevelAppPort
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import ~sitearg~
|
import ~sitearg~
|
||||||
@ -62,15 +62,15 @@ with~sitearg~ conf logger f = do
|
|||||||
where
|
where
|
||||||
s = static Settings.staticDir
|
s = static Settings.staticDir
|
||||||
|
|
||||||
with~sitearg~LoadConfig :: Settings.AppEnvironment -> (Application -> IO a) -> IO ()
|
|
||||||
with~sitearg~LoadConfig env f = do
|
|
||||||
conf <- Settings.loadConfig env
|
|
||||||
logger <- makeLogger
|
|
||||||
with~sitearg~ conf logger f
|
|
||||||
flushLogger logger
|
|
||||||
|
|
||||||
-- for yesod devel
|
-- for yesod devel
|
||||||
withDevelApp :: Dynamic
|
withDevelAppPort :: Dynamic
|
||||||
withDevelApp = do
|
withDevelAppPort =
|
||||||
toDyn ((with~sitearg~LoadConfig Settings.Development):: (Application -> IO ()) -> IO ())
|
toDyn go
|
||||||
|
where
|
||||||
|
go :: ((Int, Application) -> IO ()) -> IO ()
|
||||||
|
go f = do
|
||||||
|
conf <- Settings.loadConfig Settings.Development
|
||||||
|
let port = appPort conf
|
||||||
|
logger <- makeLogger
|
||||||
|
with~sitearg~ conf logger $ \app -> f (port, app)
|
||||||
|
flushLogger logger
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user