Amazon web services CloudHaskell在AWS上运行
我在AWS上创建了3个EC2 Ubuntu实例,并尝试运行以下代码:Amazon web services CloudHaskell在AWS上运行,amazon-web-services,haskell,amazon-ec2,cloud-haskell,Amazon Web Services,Haskell,Amazon Ec2,Cloud Haskell,我在AWS上创建了3个EC2 Ubuntu实例,并尝试运行以下代码: module Main where remotableDecl [ [d| distribute :: ([NodeId], Int) -> Process () distribute (slaves, x) = do let x' = myMath x nextNode = slaves !! (x' `mod` (length slaves)) say $ show x ++
module Main where
remotableDecl [ [d|
distribute :: ([NodeId], Int) -> Process ()
distribute (slaves, x) = do
let x' = myMath x
nextNode = slaves !! (x' `mod` (length slaves))
say $ show x ++ " - 1 = " ++ show x'
unless (x' == 0) $
void $ spawn nextNode $ $(mkClosure 'distribute) (slaves, myMath x)
|]]
remoteTable = __remoteTableDecl initRemoteTable
master :: Backend -> [NodeId] -> Process ()
master backend slaves = do
liftIO . putStrLn $ "Slaves: " ++ show slaves
distribute (slaves, 15)
terminateAllSlaves backend
main :: IO ()
main = do
prog <- getProgName
args <- getArgs
case args of
["master", host, port] -> do
backend <- initializeBackend host port remoteTable
startMaster backend (master backend)
["slave", host, port] -> do
backend <- initializeBackend host port remoteTable
startSlave backend
modulemain其中
可移除的decl[[d]|
分发::([NodeId],Int)->进程()
分配(从机,x)=do
设x'=myMath x
nextNode=slaves!!(x'`mod`(长度从属))
说$show x++“-1=“++show x”
除非(x'==0)$
void$spawn nextNode$$(mkClosure'distribute)(从属,myMath x)
|]]
remoteTable=\uuuuRemoteTableDecl initRemoteTable
主机::后端->[NodeId]->进程()
主后端从机=do
利夫蒂奥。putStrLn$“从设备:”++显示从设备
分发(奴隶,15人)
terminateAllSlaves后端
main::IO()
main=do
prog您的问题是什么,您当前获得的输出是什么?编辑输出后,应该有从属连接,但没有。可能有什么问题?你看过手册中的建议了吗<代码>如果您尝试上述示例,但主进程找不到任何从属进程,则可能是防火墙设置不允许UDP多播(特别是,某些Linux发行版上的默认iptables可能不允许UDP多播)。
是,我启用了UDP多播。