@@ -33,6 +33,46 @@
3333-- > ["slave", host, port] -> do
3434-- > backend <- initializeBackend host port initRemoteTable
3535-- > startSlave backend
36+--
37+-- [Compiling and Running]
38+--
39+-- Save to @example.hs@ and compile using
40+--
41+-- > ghc -threaded example.hs
42+--
43+-- Fire up some slave nodes (for the example, we run them on a single machine):
44+--
45+-- > ./example slave localhost 8080 &
46+-- > ./example slave localhost 8081 &
47+-- > ./example slave localhost 8082 &
48+-- > ./example slave localhost 8083 &
49+--
50+-- And start the master node:
51+--
52+-- > ./example master localhost 8084
53+--
54+-- which should then output:
55+--
56+-- > Slaves: [nid://localhost:8083:0,nid://localhost:8082:0,nid://localhost:8081:0,nid://localhost:8080:0]
57+--
58+-- at which point the slaves should exit.
59+--
60+-- To run the example on multiple machines, you could run
61+--
62+-- > ./example slave 198.51.100.1 8080 &
63+-- > ./example slave 198.51.100.2 8080 &
64+-- > ./example slave 198.51.100.3 8080 &
65+-- > ./example slave 198.51.100.4 8080 &
66+--
67+-- on four different machines (with IP addresses 198.51.100.1..4), and run the
68+-- master on a fifth node (or on any of the four machines that run the slave
69+-- nodes).
70+--
71+-- It is important that every node has a unique (hostname, port number) pair,
72+-- and that the hostname you use to initialize the node can be resolved by
73+-- peer nodes. In other words, if you start a node and pass hostname @localhost@
74+-- then peer nodes won't be able to reach it because @localhost@ will resolve
75+-- to a different IP address for them.
3676{-# OPTIONS_GHC -fno-warn-orphans #-}
3777module Control.Distributed.Process.Backend.SimpleLocalnet
3878 ( -- * Initialization