Erlang: starting a remote node programmatically

拥有回忆 提交于 2019-12-03 07:59:34

A bit more low level that pool is the slave(3) module. Pool builds upon the functionality in slave.

Use slave:start to start a new slave.

You should probably also specify -rsh ssh on the command-line.

So use pool if you need the kind of functionality it offers, if you need something different you can build it yourself out of slave.

There's a pool(3) facility:

pool can be used to run a set of Erlang nodes as a pool of computational processors. It is organized as a master and a set of slave nodes..

pool:start/1,2 starts a new pool. The file .hosts.erlang is read to find host names where the pool nodes can be started. The slave nodes are started with slave:start/2,3, passing along Name and, if provided, Args. Name is used as the first part of the node names, Args is used to specify command line arguments.

With pool you get load distribution facility for free.

Master node may be started this way:

erl -sname poolmaster -rsh ssh

Key -rsh here specifies an alternative to rsh for starting a slave node on a remote host. We used SSH here. Make sure your box have working SSH keys, and you can authenticate to the remote hosts using these keys.

If there are no hosts in the file .hosts.erlang, then no slave nodes are started, and you can use slave:start/2,3 to start slave nodes manually passing arguments if needed.

You could, for example start a remote node:

Arg = "-mnesia_dir " ++ M,
slave:start(H, Name, Arg).

Ensure epmd(1) is up and running on the remote boxes in order to start Erlang nodes.

Hope that helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!