on master help sign in
Pass port and assets to ob profile as arguments

This avoids embedding this information into the binary.

commit1243cc809a5780f9761f973225ebf17148733f50 authorMatthew Bauer <mjbauer95@gmail.com> dateTue 11 Feb 2020, 17:12 (7 years ago) parent63b9ff5
1 file changed+4−10
lib/command/src/Obelisk/Command/Run.hs+4−10
lib/command/src/Obelisk/Command/Run.hs+4−10
@@ -88,23 +88,17 @@ profile mProfileBaseName = withProjectRoot "." $ \root -> do
8888 freePort <- getFreePort
8989 assets <- findProjectAssets root
9090 putLog Debug $ "Assets impurely loaded from: " <> assets
91− let obRunExpr = unwords
92− [ "Obelisk.Run.run"
93− , show freePort
94− , "(Obelisk.Run.runServeAsset " ++ show assets ++ ")"
95− , "Backend.backend"
96− , "Frontend.frontend"
97− ]
9891 putLog Debug "Using profiled build of project."
9992 time <- liftIO $ formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S" <$> getCurrentTime
10093 let exeSource =
10194 unlines $
10295 [ "module Main where"
10396 , "import Control.Exception"
104− , "import Reflex.Profiled" ]
97+ , "import Reflex.Profiled"
98+ , "import System.Environment" ]
10599 <> obRunImports <>
106100 [ "main :: IO ()"
107− , "main = (" <> obRunExpr <> ") `finally` writeProfilingData \"" <> profileBaseName <> ".rprof\"" ]
101+ , "main = getArgs >>= \\args -> (Obelisk.Run.run (read (args !! 0)) (Obelisk.Run.runServeAsset (args !! 1)) Backend.backend Frontend.frontend) `finally` writeProfilingData \"" <> profileBaseName <> ".rprof\"" ]
108102 -- Sane flags to enable by default, enable time profiling +
109103 -- closure heap profiling.
110104 rtsFlags = [ "+RTS", "-p", "-po" <> profileBaseName, "-hc", "-RTS" ]
@@ -119,7 +113,7 @@ profile mProfileBaseName = withProjectRoot "." $ \root -> do
119113 case code of
120114 ExitSuccess -> do
121115 liftIO $ hClose exeHandle
122− (_, _, _, ph2) <- createProcess_ "runProfExe" $ setCwd (Just root) $ setDelegateCtlc True $ proc exeFname rtsFlags
116+ (_, _, _, ph2) <- createProcess_ "runProfExe" $ setCwd (Just root) $ setDelegateCtlc True $ proc exeFname ([show freePort, T.unpack assets] <> rtsFlags)
123117 _ <- liftIO $ waitForProcess ph2
124118 pure ()
125119 ExitFailure _ -> do