Starting the erlang VM without epmd
Asked Answered
S

2

4

I'm trying to startup epmd separately from the erlang vm, in order to do monitoring on the connection handling.

This works fine, except for cases when the vm starts up before epmd.

Is there a way to make the erlang vm start without it starting the epmd on its own?

Stela answered 24/2, 2014 at 20:35 Comment(0)
C
2

Possible helpful questions/answers:

So inline with those questions/answers, I'd suggest to make the erlang vm service depend on epmd (which should be another service on its own). Also, if you run epmd as one of your very first services to run, it should be possible to make it start before erlang every time. But how to do this will actually depend on your operating system and deployment implementation details.

Also, a not-so-elegant solution, would be to change your init script, so it will wait for epmd to start, but manually. Your mileage may vary, and a very naive approach (but useful as an example) would be something like:

    while [ true ]; do
      pid=`pidof epmd`;
      if [ "$pid" == "" ]; then
        sleep 1; # Wait a bit more
      else
        break;
      fi
    done
    # Continue initialization

Note that the code should contemplate a maximum number of attempts, also pidof only works on linux, etc. Not sure I like this solution, but can do the job.

And as less elegant solutions, you could replace the epmd that erlang will run with a binary of your own, that does whatever you need (like faking the epmd start or running your own, like in the code above).

Hope it helps!

Chimene answered 25/2, 2014 at 12:36 Comment(0)
A
3

As of Erlang/OTP 19.0, there is a -start_epmd command line option which can be set to true (the default) or false.

If you pass -start_epmd false on the command line and epmd is running, the Erlang node starts as usual. If epmd is not running, the Erlang node fails to start with this message:

$ erl -start_epmd false -sname foo
Protocol 'inet_tcp': register/listen error: econnrefused

If the Erlang node is not started as a distributed node (i.e., without passing -name or -sname), it neither starts nor attempts to connect to epmd, regardless of the -start_epmd setting.

Ayotte answered 10/2, 2017 at 10:18 Comment(0)
C
2

Possible helpful questions/answers:

So inline with those questions/answers, I'd suggest to make the erlang vm service depend on epmd (which should be another service on its own). Also, if you run epmd as one of your very first services to run, it should be possible to make it start before erlang every time. But how to do this will actually depend on your operating system and deployment implementation details.

Also, a not-so-elegant solution, would be to change your init script, so it will wait for epmd to start, but manually. Your mileage may vary, and a very naive approach (but useful as an example) would be something like:

    while [ true ]; do
      pid=`pidof epmd`;
      if [ "$pid" == "" ]; then
        sleep 1; # Wait a bit more
      else
        break;
      fi
    done
    # Continue initialization

Note that the code should contemplate a maximum number of attempts, also pidof only works on linux, etc. Not sure I like this solution, but can do the job.

And as less elegant solutions, you could replace the epmd that erlang will run with a binary of your own, that does whatever you need (like faking the epmd start or running your own, like in the code above).

Hope it helps!

Chimene answered 25/2, 2014 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.