Automatic restart of Erlang applications

I recently encountered an error in which the Erlang application died, resulting in a log message that looked like this:

=INFO REPORT==== 11-Jun-2010::11:07:25 ===
     application: myapp
     exited: shutdown
     type: temporary

I have no idea what caused this shutdown, but the real problem is that it did not restart. Instead, the now empty Erlang VM just sat there doing nothing.

Now, from my research, it looks like there are other β€œstart types” that you can provide to the application: β€œtransitional” and β€œpermanent”.

If I run Supervisor in an application, I can say that it makes a certain process temporary or permanent, and it will automatically restart it for me. However, according to the documentation, if I make the application temporary or permanent, it does not restart it when it dies, but it also kills all other applications.

What I really want to do is somehow tell Erlang VM that a particular application should always work, and if it is omitted, restart it. Can this be done?

(I'm not talking about deploying a supervisor on top of my application because then it's trick 22: what if my dispatcher process works? I'm looking for some kind of API or setting that I can use for Erlang monitor and restart my application for me.)

Thank!

+5
3

: , , . - :

init(_Args) ->
    {ok, {{one_for_one, 1000000, 1},
          [{ch3, {ch3, start_link, []},
            permanent, brutal_kill, worker, [ch3]}]}}.

( OTP.)

+4

heart , , , , , .

- , , , erlang VM script, , - , .

+5

Use Monit, then configure the application to complete with a supervisor for the entire application with a reasonable restart frequency. If the application terminates, the VM terminates and monit restarts everything.

I could not get Heart to be reliable enough, since it only restarts the virtual machine once, and this does not work very well with kill -9 of the erlang virtual machine.

+4
source

All Articles