A peer-based distributed application written in Haskell with an embedded web server.
This example application is different than a traditional distributed-process application because it doesn't use a master/slave configuration. Instead, all peers are equal and notify one another of their existence.
Not many. It's intentionally very minimal.
-
After starting, the application will discover peers on the local network and request from each a reply containing basic information (hostname, OS, etc.).
-
When a node receives a request for information it records the existence of the requesting peer in a mutable map. It also begins monitoring the peer for failure.
-
If a node dies or terminates peers will remove the deceased node from their node maps.
-
Nodes that were started with the
-wflag include a web server on port 8000 (use-Wto use another port.) Browsing to that port on localhost will show an automatically updating list of peers.
-
When running nodes on different machines you must use the
-Hflag to set your public IP address so other peers can see you. It would be nice if this was automatically set. -
On the other hand, when running more than one node on the same machine you need to use the
-nflag to specify a port number so that each node has a unique port. -
I've stripped out all use of Template Haskell from this application, including the remotable table. Therefore you can't spawn processes on remote nodes.
-
Install the Haskell Platform.
-
Install cabal-dev:
$ cabal update $ cabal install cabal-dev
-
Build
distinfo:$ cd distinfo $ cabal-dev install
-
Play with it:
$ cabal-dev/bin/distinfo --help