[erlang-questions] Distributed Applications: Stop Before Start?

Vance Shipley <>
Tue Mar 27 16:01:23 CEST 2012


Is there a clever way to get "stop first" semantics out of dist_ac?

A distributed application in OTP may migrate from a failed node
to another and it may migrate back when the original node returns.

You can initiate a transfer with application:permit(foo, false).
The order of the callbacks is:

                     
   ---------------------   -------------------
                           foo_app:start({takeover, }, [])
                           foo_app:start_phase(phase1, {takeover, }, [])
                           foo_app:start_phase(phase2, {takeover, }, [])
   foo_app:prep_stop([])
   foo_app:stop([])

Only the start/2 and stop/1 callbacks are required, the others are optional.

I'm currently trying to distribute OTP's snmp application between two
nodes on the same host but it fails in the situation above because it
tries to bind to the address already in use:

     ** Configuration error: failed starting net-if: 
     {udp_open,161,eaddrinuse}

So in this case I'd like to have the application stopped on the old
node before it is started on the new node.

-- 
	-Vance



More information about the erlang-questions mailing list