-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevel.hs
40 lines (36 loc) · 1.11 KB
/
devel.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (race_)
import "hookmark" Hookmark.Web (HookmarkWeb (..))
import Network.HTTP.Types
import Network.Wai
import Network.Wai.Handler.Warp
import Network.Wai.Middleware.RequestLogger
import System.Directory (doesFileExist)
import System.Environment
import System.FilePath
import Yesod
main :: IO ()
main = develMain
develMain :: IO ()
develMain = do
race_ watchTermFile $ do
port <- read <$> getEnv "PORT"
displayPort <- getEnv "DISPLAY_PORT"
putStrLn $ "Running in development mode on port " ++ show port
putStrLn $ "But you should connect to port " ++ displayPort
app <- toWaiApp HookmarkWeb {hookmarkWebBaseDir = "regression/testmarks"}
run port $ logStdoutDev app
-- | Would certainly be more efficient to use fsnotify, but this is
-- simpler.
watchTermFile :: IO ()
watchTermFile = loop
where
loop = do
exists <- doesFileExist "yesod-devel/devel-terminate"
if exists
then return ()
else do
threadDelay 100000
loop