imp:web: more accurate startup messages, eg with --socket [#2127]
This commit is contained in:
parent
569d2c8e5f
commit
80ebd18d08
@ -80,9 +80,25 @@ web opts j = do
|
|||||||
,appExtra = Extra "" Nothing staticRoot
|
,appExtra = Extra "" Nothing staticRoot
|
||||||
}
|
}
|
||||||
app <- makeApplication opts j' appconfig
|
app <- makeApplication opts j' appconfig
|
||||||
-- XXX would like to allow a host name not just an IP address here
|
|
||||||
_ <- printf "Serving web %s on %s:%d with base url %s\n"
|
-- show configuration
|
||||||
(if serve_api_ opts then "API" else "UI and API" :: String) h p u
|
let
|
||||||
|
services | serve_api_ opts = "json API"
|
||||||
|
| otherwise = "web UI and json API"
|
||||||
|
prettyip ip
|
||||||
|
| ip == "127.0.0.1" = ip ++ " (local access)"
|
||||||
|
| ip == "0.0.0.0" = ip ++ " (all interfaces)"
|
||||||
|
| otherwise = ip
|
||||||
|
listenat =
|
||||||
|
case socket_ opts of
|
||||||
|
Just s -> printf "socket %s" s
|
||||||
|
Nothing -> printf "IP address %s, port %d" (prettyip h) p
|
||||||
|
printf "Serving %s at %s\nwith base url %s\n" (services::String) (listenat::String) u
|
||||||
|
case file_url_ opts of
|
||||||
|
Just fu -> printf "and static files base url %s\n" fu
|
||||||
|
Nothing -> pure ()
|
||||||
|
|
||||||
|
-- start server and maybe browser
|
||||||
if serve_ opts || serve_api_ opts
|
if serve_ opts || serve_api_ opts
|
||||||
then do
|
then do
|
||||||
putStrLn "Press ctrl-c to quit"
|
putStrLn "Press ctrl-c to quit"
|
||||||
@ -108,7 +124,9 @@ web opts j = do
|
|||||||
putStrLn "Unix domain sockets are not available on your operating system"
|
putStrLn "Unix domain sockets are not available on your operating system"
|
||||||
putStrLn "Please try again without --socket"
|
putStrLn "Please try again without --socket"
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
Nothing -> Network.Wai.Handler.Warp.runSettings warpsettings app
|
Nothing -> Network.Wai.Handler.Warp.runSettings warpsettings app
|
||||||
|
|
||||||
else do
|
else do
|
||||||
putStrLn "This server will exit after 2m with no browser windows open (or press ctrl-c)"
|
putStrLn "This server will exit after 2m with no browser windows open (or press ctrl-c)"
|
||||||
putStrLn "Opening web browser..."
|
putStrLn "Opening web browser..."
|
||||||
|
|||||||
@ -22,7 +22,7 @@ staticSite :: IO Static
|
|||||||
staticSite =
|
staticSite =
|
||||||
if development
|
if development
|
||||||
then (do
|
then (do
|
||||||
putStrLn ("Using web files from: " ++ staticDir ++ "/") >> hFlush stdout
|
putStrLn ("Running in dev mode, will read static files from " ++ staticDir ++ "/") >> hFlush stdout
|
||||||
staticDevel staticDir)
|
staticDevel staticDir)
|
||||||
else (do
|
else (do
|
||||||
-- putStrLn "Using built-in web files" >> hFlush stdout
|
-- putStrLn "Using built-in web files" >> hFlush stdout
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user