-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.hs
More file actions
executable file
·51 lines (40 loc) · 1.44 KB
/
Build.hs
File metadata and controls
executable file
·51 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env stack
-- stack runhaskell --package async --package unix --
{-|
A simple script to build and run all components of the ''One Log'' talk
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wall -Werror #-}
import Color
import Control.Concurrent.Async
import Control.Concurrent.Chan
import Control.Monad (void)
import Log
import Process
import System.Environment (getArgs)
import System.IO
main :: IO ()
main = do
args <- getArgs
case args of
["run"] -> doRun
["build"] -> doBuild
["test"] -> doTest
_ -> putStrLn "expecting one of 'run' or 'build'"
doBuild :: IO ()
doBuild = do
runProc "mvn" [ "install" ] "pet-store-payment"
runProc "stack" [ "test", "--fast" ] "."
runProc "stack" [ "install", "--fast" ] "."
doTest :: IO ()
doTest = runProc "stack" [ "exec", "driver-petstore", "--" ,"1", "localhost", "9090" ] "."
doRun :: IO ()
doRun = do
q <- newChan
t <- tailLogs q stdout
let procs = [ ( "java", [ "-jar" , "./pet-store-payment/target/pet-store-payment-1.0-SNAPSHOT.jar", "server", "payment-conf.yaml" ], ".")
, ( "pet-store-server", [ "Dev" , "9090", "localhost", "8080" ], ".")
]
ps <- concat <$> mapM (\ ((name, args, dir), clr) -> spawnProc clr q name args dir) (zip procs genColors)
void $ waitAnyCancel (t:ps)