diff options
-rw-r--r-- | src/Command/Run.hs | 4 | ||||
-rw-r--r-- | src/Job.hs | 11 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/Command/Run.hs b/src/Command/Run.hs index 403e8b8..c762335 100644 --- a/src/Command/Run.hs +++ b/src/Command/Run.hs @@ -58,7 +58,7 @@ cmdRun (RunCommand changeset) = do tout <- getTerminalOutput liftIO $ do - mngr <- newJobManager optJobs + mngr <- newJobManager "./.minici" optJobs Just repo <- openRepo "." commits <- listCommits repo (base <> ".." <> tip) jobssets <- mapM loadJobSetForCommit commits @@ -74,7 +74,7 @@ cmdRun (RunCommand changeset) = do shortDesc = fitToLength 50 (commitDescription commit) case jobsetJobsEither jobset of Right jobs -> do - outs <- runJobs mngr "./.minici" commit jobs + outs <- runJobs mngr commit jobs let findJob name = snd <$> find ((name ==) . jobName . fst) outs displayStatusLine tout shortCid (" " <> shortDesc) $ map findJob names return $ map snd outs @@ -90,6 +90,7 @@ textJobStatus = \case data JobManager = JobManager { jmSemaphore :: TVar Int + , jmDataDir :: FilePath , jmJobs :: TVar (Map JobId (TVar (JobStatus JobOutput))) , jmNextTaskId :: TVar TaskId , jmNextTask :: TVar (Maybe TaskId) @@ -99,8 +100,8 @@ data JobManager = JobManager newtype TaskId = TaskId Int deriving (Eq, Ord) -newJobManager :: Int -> IO JobManager -newJobManager queueLen = do +newJobManager :: FilePath -> Int -> IO JobManager +newJobManager jmDataDir queueLen = do jmSemaphore <- newTVarIO queueLen jmJobs <- newTVarIO M.empty jmNextTaskId <- newTVarIO (TaskId 0) @@ -146,8 +147,8 @@ runManagedJob JobManager {..} tid job = bracket acquire release (\_ -> job) writeTVar jmNextTask (Just tid') -runJobs :: JobManager -> FilePath -> Commit -> [ Job ] -> IO [ ( Job, TVar (JobStatus JobOutput) ) ] -runJobs mngr@JobManager {..} dir commit jobs = do +runJobs :: JobManager -> Commit -> [ Job ] -> IO [ ( Job, TVar (JobStatus JobOutput) ) ] +runJobs mngr@JobManager {..} commit jobs = do treeId <- readTreeId commit results <- atomically $ do forM jobs $ \job -> do @@ -177,7 +178,7 @@ runJobs mngr@JobManager {..} dir commit jobs = do uses <- waitForUsedArtifacts job results outVar runManagedJob mngr tid $ do liftIO $ atomically $ writeTVar outVar JobRunning - prepareJob dir commit job $ \checkoutPath jdir -> do + prepareJob jmDataDir commit job $ \checkoutPath jdir -> do updateStatusFile (jdir </> "status") outVar JobDone <$> runJob job uses checkoutPath jdir |