Using Erlang Heart

How to use the heart to save the application?

Let's say that I have an application X, will it be controlled if I just call something like:

erl -boot X -heart -env HEART_BEAT_TIMEOUT 30 -detached

?

+5
source share
2 answers

Yes, this will automatically start the heart process that will control your node. See documentation for heart .

Update: Yes, Asymptot is correct. You will also need an environment variable HEART_COMMANDto make it clear what to do when the node restarts.

+4
source

http://www.erlang.org/doc/man/heart.html

This modules contains the interface to the heart process. heart
sends periodic heartbeats to an external port program, which is
also named `heart`. The purpose of the heart port program is to
check that the Erlang runtime system it is supervising is still
running. If the port program has not received any heartbeats within
`HEART_BEAT_TIMEOUT` seconds (default is 60 seconds), the system
can be rebooted. Also, if the system is equipped with a hardware
watchdog timer and is running Solaris, the watchdog can be used to
supervise the entire system.

<snip>

If the system should be rebooted because of missing heart-beats, or
a terminated Erlang runtime system, the environment variable
HEART_COMMAND has to be set before the system is started. If this
variable is not set, a warning text will be printed but the system
will not reboot.

Makefile , erl -heart ... . , :

ubuntu    3814  3579  3814  3579  0 22:03 pts/0    00:00:00           make webstart
ubuntu    3829  3814  3814  3579 25 22:03 pts/0    00:00:01             /usr/local/lib/erlang/erts-5.8.3/bin/beam.smp -K true -A 5
ubuntu    3848  3829  3848  3848  0 22:03 ?        00:00:00               heart -pid 3829

PID 3829, Erlang :

heart: Wed May 18 22:04:09 2011: Erlang has closed.
heart: Wed May 18 22:04:09 2011: Would reboot. Terminating.
make: *** [webstart] Terminated

HEART_COMMAND - , . AFAIK, , , Erlang VM ; -, Erlang, .

(, HEART_COMMAND, Erlang).

+2

All Articles