raketka-1.2.0: src/Main.hs
module Main where
import Debug.Trace
import Data.Conf.Json
import System.Environment
import Control.Distributed.Process.Closure
import Control.Distributed.Process.Backend.SimpleLocalnet
import Control.Distributed.Process.Node as Node hiding (newLocalNode)
import Control.Distributed.Raketka.Master
import Control.Distributed.Raketka.Type.Arg
import Control.Distributed.Raketka.Impl.Inst as I
import Control.Distributed.Raketka.Type.Server
remotable ['I.server]
main :: IO()
main = do
args <- getArgs
case args of
[path0, idx0] -> do
Right c1 @ (Cluster conf1) <- readParse path0::IO (Either String Cluster)
let idx1 = read idx0 :: Int
idKnown c1 $ Slb idx1
_ -> do
traceIO "expect 2 args :"
traceIO "1) path to a config file. See ./test-conf.json for an example"
traceIO "2) 0 based node index"
idKnown :: Cluster -> Slb Int -> IO()
idKnown cl1@(Cluster cl0) idx0 = do
backend1 <- initializeBackend (host id1) thisport1
(__remoteTable initRemoteTable)
node1 <- newLocalNode backend1
Node.runProcess node1
(master backend1 cl1
idx0
())
where thisport1 = show $ port id1
id1 = cl0 !! (untag idx0)