gmile

gmile

Spawning a new VM node dynamically

Hi all,

I’m trying to test communication between two Erlang VM nodes. There’s a way to do so in Erlang by using CT Slave http://erlang.org/doc/man/ct_slave.html.

I’ve tested it and so far it looks like I can spawn new nodes pretty easily using ct_slave.start. However, all such nodes are “blank”, e.g. no app’s code is loaded in them. And I can’t seem to figure out how to spawn a node with my app’s own code.

I began the investigation.

From looking at the running processes using ps, here’s what I see:

Programmatically ran node:

61133   ??  S      0:00.16 /usr/local/Cellar/erlang/19.1/lib/erlang/erts-8.1/bin/beam.smp -- -root /usr/local/Cellar/erlang/19.1/lib/erlang -progname erl -- -home /Users/gmile -- -noshell -noinput -noshell -noinput -setcookie WYNSTOZWBNWPAJPYXXZW -sname yo@localhost

Node, ran normally via iex -S mix run:

58597   ??  S      0:04.24 /usr/local/Cellar/erlang/19.1/lib/erlang/erts-8.1/bin/beam.smp -- -root /usr/local/Cellar/erlang/19.1/lib/erlang -progname erl -- -home /Users/gmile -- -pa /usr/local/Cellar/elixir/1.3.4/bin/../lib/eex/ebin /usr/local/Cellar/elixir/1.3.4/bin/../lib/elixir/ebin /usr/local/Cellar/elixir/1.3.4/bin/../lib/ex_unit/ebin /usr/local/Cellar/elixir/1.3.4/bin/../lib/iex/ebin /usr/local/Cellar/elixir/1.3.4/bin/../lib/logger/ebin /usr/local/Cellar/elixir/1.3.4/bin/../lib/mix/ebin -noshell -s elixir start_cli -sname testnode1@localhost -setcookie test_cookie -extra --sname testnode1@localhost --cookie test_cookie --no-halt -S mix run

From looking at the second, “normal” output, it looks like mix generates all the ebin paths and appends them as arguments to beam.smp.

Thus my question is – how can I have Mix give me a list of all these ebin paths, so that I could provide them manually to :ct_slave.start, e.g. when spawning a new node programmatically?

Marked As Solved

sasajuric

sasajuric

Author of Elixir In Action

Not sure about :ct_slave, but Phoenix PubSub tests spawn additional nodes with :slave, and use some extra code to transfer the app. You can see the code here.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement