sbs

sbs

Elixir 1.9 release daemon vs daemon_iex

Elixir 1.9’s mix release provide two ways to start beam in background, daemon and daemon_iex. As far as I know, both will start beam in background, and daemon_iex will also start iex in background, but you cannot interactive with that. You still need to use remote to start another beam and connect to it to interact with it. So what’s the point of daemon_iex? Or am I missing anything here?

Most Liked

sbs

sbs

Here’s a (incomplete) comparison between elixir 1.9 and distillery.

    +------------+----------------+
    | elixir1.9  | 1.8+distillery |
    +------------+----------------+
    | start      | foreground     |
    | start_iex  | console        |
    | daemon     | n/a            |
    | daemon_iex | start          |
    | remote     | remote_console |
    | stop       | stop           |
    | pid        | pid            |
    | n/a        | ping           |
    | n/a        | attach         |
    +------------+----------------+

So the reason that attach is removed is mainly because when people attach to a background beam, it’s easy to kill the beam by accident if they didn’t use ctrl-d to detach.

So the daemon_iex is same as distillery’s start, where you can attach to the beam with iex. If we use daemon, then we can only interact with the background beam by remote to it. Even if we use to_erl to attach to it, we are unable to interact with it since iex is not started.

I think it’s worth mention the difference in the doc. Because it’s kinda confusing on what daemon_iex is do, and I guess most people don’t know what run_erl or to_erl does, since we rarely use them directly.

14
Post #3
josevalim

josevalim

Creator of Elixir

Both daemon options can be interacted with using the to_erl executable and pointing it to tmp/pipe/ (trailing / is important):

$ mix release
$ cd _build/dev/rel/my_app
$ bin/my_app daemon_iex
$ to_erl /tmp/pipe/

More information in the docs: https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-daemon-mode-unix-like

BlindingDark

BlindingDark

@Merff @noisykeyboard

If you modify the epmd port, you need to specify it.

ELIXIR_ERL_OPTIONS="-epmd_port 12345" RELEASE_DISTRIBUTION=name RELEASE_NODE=name@exaple.com RELEASE_COOKIE=secret _build/prod/rel/my_app/bin/my_app stop

The specific reason is because the start command loads the vm.args file, while rpc does not.

You can open _build/prod/rel/my_app/bin/my_app to see the specific implementation

case $1 i
  start)
    start "elixir" --no-halt
    ;;

  restart|stop)
    rpc "System.$1"
    ;;

// ...

rpc () {
  exec "$REL_VSN_DIR/elixir" \
       --hidden --cookie "$RELEASE_COOKIE" \
       --$RELEASE_DISTRIBUTION "rpc-$(rand)-$RELEASE_NODE" \
       --boot "$REL_VSN_DIR/$RELEASE_BOOT_SCRIPT_CLEAN" \
       --boot-var RELEASE_LIB "$RELEASE_ROOT/lib" \
       --rpc-eval "$RELEASE_NODE" "$1"
}

start () {
  export_release_sys_config
  REL_EXEC="$1"
  shift
  exec "$REL_VSN_DIR/$REL_EXEC" \
       --cookie "$RELEASE_COOKIE" \
       --$RELEASE_DISTRIBUTION "$RELEASE_NODE" \
       --erl "-mode $RELEASE_MODE" \
       --erl-config "$RELEASE_SYS_CONFIG" \
       --boot "$REL_VSN_DIR/$RELEASE_BOOT_SCRIPT" \
       --boot-var RELEASE_LIB "$RELEASE_ROOT/lib" \
       --vm-args "$RELEASE_VM_ARGS" "$@"
}

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
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
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
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

We're in Beta

About us Mission Statement