[erlang-questions] Best approach to stop distributed erlang apps

Michael McDaniel erlangy@REDACTED
Thu May 15 00:03:15 CEST 2008


On Wed, May 14, 2008 at 04:34:09PM -0400, Rick Pettit wrote:
> On Wed, May 14, 2008 2:44 pm, Dave Bryson wrote:
> > I have an application distributed across X number of machines in a
> > cluster.  I'm currently launching the apps in a -detached mode. To
> > launch the apps, I'm using a shell script that loops through the nodes
> > and runs a start script via SSH.  I'd like to be able to do the same
> > thing to stop the apps ( completely stop the erlang runtime
> > init:stop() ).  However, I  haven't been able to figure out the best
> > approach to do that.  The only thing I've been successful with is to -
> > remsh into each application and call "init:stop()".
> >
> > Does anyone have a "best practice" approach to automate calling
> > init:stop() across a cluster?
> 
> If order doesn't matter and a clean shutdown which flushes all I/O isn't
> required you should be able to do something like:
> 
>   StopNode=fun(N) -> rpc:call(N,init,stop,[]) end,
>   lists:foreach(StopNode, nodes()).
> 
> -Rick
> 
> P.S. I have not tested the code above :-)
> 
______________________________________________________________________

 Or, presuming that your distributed nodes are accepting messages,
 accept a 

 {From, stop} -> check that From is a friend and cleanup my junk ,
                 init:stop() ;

 message type in your receive loop.

 I use a configuration file containing a list of just who a "friend" is,
 i.e. who can send a valid stop command.


~Michael



More information about the erlang-questions mailing list