5

The title pretty much sums it up. I have a zotonic site running with -heart, it uses lots of cpu time and I can't get an erlang shell. So, is there a way to kill the vm? killall heart and killall beam.smp are not working.

I found this question: Stop Erlang Daemon , but it does not really answer my question.

Community
  • 1
  • 1
Simon Lindgren
  • 500
  • 1
  • 6
  • 14
  • 3
    In my experience first killing heart followed by killing beam or beam.smp does the trick. – Steve Vinoski Aug 28 '11 at 13:29
  • @Steve I did try that without success. I have since found the problem of not being able to get a shell, namely this: http://groups.google.com/group/zotonic-users/browse_thread/thread/b3971b574e405bcc?pli=1. So I solved this by solving the underlying issue it seems :). Still, I think how to do this should be better documented (somewhere). – Simon Lindgren Sep 06 '11 at 10:54
  • 1
    Kill heart and then beam, in one command line. Always works for me. We (the Zotonic team) are looking at non-heart solutions. – Marc Worrell Mar 28 '13 at 10:05
  • For anyone who stumbles across this: I much prefer supervisord to heart - it's behavior is more easily customizable and it works for non-erlang things, meaning as you learn its nuances those learnings are more applicable. – James Kingsbery Aug 03 '15 at 22:13

3 Answers3

3

Just use:

init:stop().

It will kill the heart process and all applications.

Isac
  • 2,058
  • 16
  • 23
  • 1
    But he said he can't get an Erlang shell, because the process is using too much CPU, so I don't think this helps in this particular case. – Steve Vinoski Aug 29 '11 at 18:40
  • When I tried this from `remsh`, `heart` didn't die and it restarted the `remsh` node and the original node. – Michael Terry Jul 05 '18 at 04:58
2

I had this same issue.... And it was really hard to kill it. I tried the normal paths and couldn't do it. So I did this hack:

First let's get the PID

sudo netstat -tulpn |grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      931/beam.smp    

So the PID is 931.

Next which program created that process?

lsof -p 931 | grep txt
lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/agarcia/.gvfs
      Output information may be incomplete.
beam.smp 931 yaws  txt    REG     8,1  2053256 22793377 /usr/lib/erlang/erts-5.8.5/bin/beam.smp

So the program is .../bin/beam.smp so just move it

mv beam.smp old_beam.smp 

And now you kill it

kill -9 931

And I finally was able to kill it :-)

It's a testament to erlangs reliability that one actually needs to hack-it in order to be able to take down the service.

ps: I originally tried yaws -I [pid] --stop but it didn't work either.

elviejo79
  • 4,592
  • 2
  • 32
  • 35
0

If you don't mind killing every VM on your machine:

ps aux | grep -e heart -e epmd | grep -v grep | tr -s ' ' | cut -d ' ' -f 2 | xargs kill -9

The VM and heart seem to monitor each other mutually. In case the VM is in a crash/revive loop, you may need to run this command several times quickly to kill everything dead.

Michael Terry
  • 983
  • 11
  • 18