Pergunta

Como o coração deve ser usado para manter um aplicativo ativo?

Digamos que eu tenha um aplicativo X. Ele será monitorado se eu chamar algo como:

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

?

Foi útil?

Solução

Sim, isso iniciará automaticamente um processo cardíaco que monitora seu nó.Ver a documentação do coração.

Atualizar: Sim, a Assíntota está correta.Você também precisa de um HEART_COMMAND variável de ambiente para instruir o coração sobre o que fazer ao reiniciar o nó.

Outras dicas

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.

Neste momento eu tenho um Makefile com uma declaração que será executada erl -heart ... para mim.Quando eu executo aqui está a lista de processos:

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

Quando eu mato o PID 3829, a seguinte saída aparece no shell 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

Então, claramente, preciso definir HEART_COMMAND para algum tipo de instrução de reinicialização e então o coração funcionará conforme necessário.AFAIK, dada a descrição nos documentos, o coração não se destina a simplesmente reiniciar a VM Erlang em caso de falha;isso parece algo que um supervisor de Erlang deveria fazer por você, mas posso estar errado.

(Claro, você pode obter apenas HEART_COMMAND para reiniciar seu programa Erlang).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top