blob: fa27ae7dd9f64dc3c93ce0eef64e2e867d2fbdf7 (
plain)
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
|
module Main (main) where
import Control.Concurrent
import Control.Monad (replicateM_)
import Snap.Http.Server
import qualified System.Process as Pr
makeWorker :: IO ()
makeWorker = do
_ <- forkIO $ do
Pr.withCreateProcess (Pr.proc "./sleep.sh" []) $ \_ _ _ _ -> do
threadDelay 1000000
return ()
makePool :: Int -> IO ()
makePool numWorkers = replicateM_ numWorkers makeWorker
main :: IO ()
main = do
nprocs <- getNumCapabilities
putStrLn $ "Starting worker with " ++ show nprocs ++ " threads (use +RTS -N<n> to set)"
_ <- makePool nprocs
httpServe defaultConfig (return ())
|