-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): make client request for "CreateTest" do db I/O and res…
…pond
- Loading branch information
1 parent
c65312d
commit 437ebd6
Showing
6 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module Main where | ||
|
||
import StuntDouble | ||
import Control.Concurrent.Async (cancel) | ||
import Control.Exception (throwIO) | ||
import System.Environment (getEnv) | ||
import System.FilePath ((</>)) | ||
import System.IO.Error (catchIOError, isDoesNotExistError) | ||
|
||
import Scheduler | ||
import StuntDouble | ||
|
||
------------------------------------------------------------------------ | ||
|
||
getDbPath :: IO FilePath | ||
getDbPath = do | ||
getEnv "DETSYS_DB" | ||
`catchIOError` \(e :: catchIOError) -> | ||
if isDoesNotExistError e | ||
then do | ||
home <- getEnv "HOME" | ||
return (home </> ".detsys.db") | ||
else throwIO e | ||
|
||
main :: IO () | ||
main = do | ||
let executorPort = 3004 | ||
executorRef = RemoteRef ("http://localhost:" ++ show executorPort) 0 | ||
el <- makeEventLoop realTime (makeSeed 0) HttpSync (EventLoopName "scheduler") | ||
lref <- spawn el (fakeScheduler executorRef) initState | ||
putStrLn "Scheduler is running..." | ||
waitForEventLoopQuit el | ||
schedulerPort = 3005 | ||
fp <- getDbPath | ||
el <- makeEventLoop realTime (makeSeed 0) HttpSync (RealDisk fp) (EventLoopName "scheduler") | ||
now <- getCurrentTime realTime | ||
lref <- spawn el (fakeScheduler executorRef) (initState now (makeSeed 0)) | ||
withHttpFrontend el lref schedulerPort $ \pid -> do | ||
putStrLn ("Scheduler is listening on port: " ++ show schedulerPort) | ||
waitForEventLoopQuit el | ||
cancel pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters