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 #2
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: mix release — Mix v1.20.2

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

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
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 ...
1144 55125 245
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
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
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement