1

I am trying to create an application that can run on two different machines on the same network, and when one of the applications crahes, I want to use erlang heartbeat system to make it restart. How can I do this?

I've read the documentation, but have not figured out how to achieve this in practice.

Thanks

kristian X
  • 21
  • 1

1 Answers1

1

Did you specifically read http://erlang.org/doc/man/heart.html and try to follow the instructions there? In particular, you have to first set the environment variable HEART_COMMAND to the full command line to be used to restart your system.

To make this easier, you could use a launch script like this:

#!/bin/sh
erl -detached -heart -env HEART_COMMAND "$0 $@" -env HEART_BEAT_TIMEOUT 20 -sname mynode

In some environments (such as embedded systems) you might prefer a full OS reboot, and could simply run something like this:

#!/bin/sh
erl -detached -heart -env HEART_COMMAND "reboot" -env HEART_BEAT_TIMEOUT 20 -sname mynode
RichardC
  • 10,412
  • 1
  • 23
  • 24
  • I've tried to open the erlang (in ubutnu) shell using: "erl -heart -env HEART_BEAT_TIMEOUT 20 -env HEART_COMMAND heart -shutdown" and quit the shell by using CTRL + Z. after 20 seconds I get the error: "heart: Wed Apr 11 17:23:10 2018: Erlang has closed." and nothing happens. – kristian X Apr 11 '18 at 15:20
  • That part of the docs is cryptic. "heart -shutdown" only works on Windows and only exists to help trigger a reboot on a Windows machine (it has no effect at all on other platforms). On Unix-like systems, you could simply use "reboot", "sudo reboot", or similar. – RichardC Apr 13 '18 at 08:58