1{-# LANGUAGE TemplateHaskell #-}
3import Data.Binary (encode, decode)
4import Control.Applicative ((<$>))
5import Control.Monad (forever)
6import Control.Monad.IO.Class (liftIO)
7import Control.Concurrent (threadDelay)
8import Control.Exception (try, IOException)
9import Control.Distributed.Process
19 , ProcessMonitorNotification(..)
21import Control.Distributed.Process.Closure
24 , SerializableDict(..)
27import Control.Distributed.Process.Backend.Azure.GenericMain
31import qualified Data.ByteString.Lazy as BSL (readFile, writeFile)
33sdictString :: SerializableDict String
34sdictString = SerializableDict
36ping :: () -> Process String
38 mPingServerEnc <- liftIO $ try (BSL.readFile "pingServer.pid")
39 case mPingServerEnc of
41 return $ "Ping server not found: " ++ show (err :: IOException)
42 Right pingServerEnc -> do
43 let pingServer = decode pingServerEnc
47 gotReply <- receiveWait
48 [ match (\() -> return True)
49 , match (\(ProcessMonitorNotification _ _ _) -> return False)
52 then return $ "Ping server at " ++ show pingServer ++ " ok"
53 else return $ "Ping server at " ++ show pingServer ++ " failure"
55pingServer :: () -> Process ()
58 liftIO $ BSL.writeFile "pingServer.pid" (encode pid)
63remotable ['ping, 'pingServer, 'sdictString]
66main = genericMain __remoteTable callable spawnable
68 callable :: String -> IO (ProcessPair ())
69 callable "ping" = return $ ProcessPair ($(mkClosure 'ping) ()) putStrLn $(mkStatic 'sdictString)
70 callable _ = error "spawnable: unknown"
72 spawnable :: String -> IO (Closure (Process ()))
73 spawnable "pingServer" = return $ $(mkClosure 'pingServer) ()
74 spawnable _ = error "callable: unknown"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list