on master help sign in
Delay getting port or assets until right before the
4916971Matthew Bauer
lib/command/src/Obelisk/Command/Run.hs+13−14
@@ -84,9 +84,6 @@ profile
84 => FilePath
84 => FilePath
85 -> m ()
85 -> m ()
86profile profileBaseName = withProjectRoot "." $ \root -> do
86profile profileBaseName = withProjectRoot "." $ \root -> do
87− freePort <- getFreePort
88− assets <- findProjectAssets root
89− putLog Debug $ "Assets impurely loaded from: " <> assets
90 putLog Debug "Using profiled build of project."
87 putLog Debug "Using profiled build of project."
91 liftIO $ createDirectoryIfMissing False $ takeDirectory profileBaseName
88 liftIO $ createDirectoryIfMissing False $ takeDirectory profileBaseName
92 let -- Sane flags to enable by default, enable time profiling +
89 let -- Sane flags to enable by default, enable time profiling +
@@ -113,6 +110,9 @@ profile profileBaseName = withProjectRoot "." $ \root -> do
113 { _target_path = Nothing
110 { _target_path = Nothing
114 , _target_attr = Nothing
111 , _target_attr = Nothing
115 , _target_expr = Just nixBuildExpr }
112 , _target_expr = Just nixBuildExpr }
113+ assets <- findProjectAssets root
114+ putLog Debug $ "Assets impurely loaded from: " <> assets
115+ freePort <- getFreePort
116 (_, _, _, ph) <- createProcess_ "runProfExe" $ setCwd (Just root) $ setDelegateCtlc True $ proc exePath ([show freePort, T.unpack assets] <> rtsFlags)
116 (_, _, _, ph) <- createProcess_ "runProfExe" $ setCwd (Just root) $ setDelegateCtlc True $ proc exePath ([show freePort, T.unpack assets] <> rtsFlags)
117 _ <- liftIO $ waitForProcess ph
117 _ <- liftIO $ waitForProcess ph
118 pure ()
118 pure ()
@@ -122,18 +122,17 @@ run
122 => m ()
122 => m ()
123run = withProjectRoot "." $ \root -> do
123run = withProjectRoot "." $ \root -> do
124 pkgs <- fmap toList . parsePackagesOrFail =<< getLocalPkgs root
124 pkgs <- fmap toList . parsePackagesOrFail =<< getLocalPkgs root
125− freePort <- getFreePort
126− assets <- findProjectAssets root
127− putLog Debug $ "Assets impurely loaded from: " <> assets
128− let obRunExpr = unwords
129− [ "Obelisk.Run.run"
130− , show freePort
131− , "(Obelisk.Run.runServeAsset " ++ show assets ++ ")"
132− , "Backend.backend"
133− , "Frontend.frontend"
134− ]
135 withGhciScript pkgs root $ \dotGhciPath -> do
125 withGhciScript pkgs root $ \dotGhciPath -> do
126+ freePort <- getFreePort
127+ assets <- findProjectAssets root
128+ putLog Debug $ "Assets impurely loaded from: " <> assets
136− runGhcid root True dotGhciPath pkgs $ Just obRunExpr
129+ runGhcid root True dotGhciPath pkgs $ Just $ unwords
130+ [ "Obelisk.Run.run"
131+ , show freePort
132+ , "(Obelisk.Run.runServeAsset " ++ show assets ++ ")"
133+ , "Backend.backend"
134+ , "Frontend.frontend"
135+ ]
137
136
138runRepl :: MonadObelisk m => m ()
137runRepl :: MonadObelisk m => m ()
139runRepl = withProjectRoot "." $ \root -> do
138runRepl = withProjectRoot "." $ \root -> do