git.iko.soy/distributed-process
on fd61d21 help sign in
24 lines 791 B history raw
1import System.Environment (getArgs, getProgName)
2import Control.Distributed.Process (NodeId, Process, liftIO)
3import Control.Distributed.Process.Node (initRemoteTable)
4import Control.Distributed.Process.Backend.SimpleLocalnet
6master :: Backend -> [NodeId] -> Process ()
7master backend slaves = do
8 liftIO . putStrLn $ "Slaves: " ++ show slaves
9 terminateAllSlaves backend
11main :: IO ()
12main = do
13 prog <- getProgName
14 args <- getArgs
16 case args of
17 ["master", host, port] -> do
18 backend <- initializeBackend host port initRemoteTable
19 startMaster backend (master backend)
20 ["slave", host, port] -> do
21 backend <- initializeBackend host port initRemoteTable
22 startSlave backend
23 _ ->
24 putStrLn $ "usage: " ++ prog ++ " (master | slave) host port"