[erlang-questions] Automatically reconnecting nodes when they come back online

Dmitry Kolesnikov dmkolesnikov@REDACTED
Mon Apr 29 09:24:10 CEST 2013


I am using the following approach for similar issue.

- net_kernel:monitor allow your process to receive nodeup/nodedown events.

- the player nodes requires a list of 'seed' nodes at config file. It should connect those seed nodes at boot time. If none of seeds is connected then player node has to die with alarm.

- Dmitry

On Apr 29, 2013, at 9:41 AM, Ignas Vyšniauskas <baliulia@REDACTED> wrote:

> On 04/26/2013 07:00 PM, Scott Thoman wrote:
>> My first two thoughts were: 1.  When the conductor node connects up
>> the player nodes it would also spawn a process whose sole job is to
>> periodically ping the other nodes to ensure they're connected.  Then
>> when one goes down, those pings will just fail during that time but
>> when the node comes back a ping will reconnect it to the other
>> nodes. All this time, I'd be monitoring the node up/down messages. 2.
>> I'd start by monitoring all the nodes as the conductor connects them
>> and when receiving a node down message, spawn a process whose job it
>> is to periodically ping only that node only until it comes back.
> * you don't need a pinging mechanism, just use the existing
> `net_kernel:monitor(true)` and handle the events.
> * if you can afford a fixed node name for at least the "conductor" node,
> then you can do something along the lines you described yourself --
> should be trivial.
> * otherwise you can try to hack things using `net_adm:world()` or
> something like that for "dynamic" node discovery
> Also, take a look at the `{sync_nodes_optional, NodeList}` parameter of
> `kernel`.
> --
> Ignas
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list