tags:

views:

390

answers:

1
+4  Q: 

Stop Erlang Daemon

Besides running $ killall -9 beam.smp, how can I kill an Erlang node programmatically when I know its -sname?

If I don't want the heartbeat monitor to restart the process, how can I ensure that whatever answer is given for the above question will also kill the heartbeat?

Is there a decent guide to deploying Erlang as a daemon?

+7  A: 

kill and killall with -9 is almost always wrong.

You can quite easily ask the remote node to exit using:

rpc:call(RemoteNode, init, stop, []).

I don't know whether that'd prevent heart from restarting it, but I'd suggest that if you expect to stop it, you shouldn't run it in a don't-ever-stop mode.

Update - Zed points out that init:stop does the right thing with heart, so the above rpc:call is the best and only way to do it.

Dustin
"init:stop(): ... If the -heart command line flag was given, the heart program is terminated before the Erlang node terminates. ..."
Zed
I think my nodes aren't quite connecting. I'm sure I'm overlooking something. To test, I opened two Terminal windows and ran `erl -sname foo` in one, then got the cookie from it and ran `erl -sname bar -setcookie '...'`. In this window, I ran `net_adm:ping('foo@elife')` but it gave me a 'pang'. I've tried some variants on this, all without luck. Any idea what I'm doing wrong?
Eli
Why are you doing `-setcookie` on one and not the other? If they don't match, you can't talk. In generally, I just use `~/.erlang.cookie` on my local node.
Dustin
I set them both to use the same cookie, but still, no communication. Any ideas?
Eli
Could be a number of things. You should definitely have that working, though. That's another question or more documentation, though. You could try `-name [email protected]` which should probably work.
Dustin
Are you running OS X? If so, this might be your problem as well: http://stackoverflow.com/questions/2136918/getting-two-erl-shells-to-talk
Adam Lindberg