6

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?

Eli
  • 1,269
  • 8
  • 17

1 Answers1

10

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
  • 89,080
  • 21
  • 111
  • 133
  • 3
    "init:stop(): ... If the -heart command line flag was given, the heart program is terminated before the Erlang node terminates. ..." – Zed Jan 25 '10 at 07:41
  • 1
    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 Jan 25 '10 at 16:07
  • 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 Jan 25 '10 at 18:14
  • I set them both to use the same cookie, but still, no communication. Any ideas? – Eli Jan 26 '10 at 00:54
  • 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 something@127.0.0.1` which should probably work. – Dustin Jan 26 '10 at 04:57
  • 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 Jan 28 '10 at 19:59