Skip to content

Instantly share code, notes, and snippets.

@jclosure
Created October 28, 2017 04:13
Show Gist options
  • Save jclosure/91a726e68feae899945c6cabdb6ba780 to your computer and use it in GitHub Desktop.
Save jclosure/91a726e68feae899945c6cabdb6ba780 to your computer and use it in GitHub Desktop.
How to debug a live elixir server

the app server must have been started with elixir --sname appname --cookie mycookie -S mix phoenix.server connect to the server via ssh

  1. start an iex Session with (important: cookies must match but can be freely chosen, names can be freely chosen too): iex --sname foo --cookie mycookie
foo@host> node = :"appname@host"

# appnames must match
foo@host> Node.connect(node)

# Erlang-top runs until it is stopped
foo@host> Node.spawn(node, fn -> :etop.start end)

# Where x,y,z is taken from the etop output of the wanted process to inspect
foo@host> pid = pid(x,y,z)

# instead of :backtrace you can do other things as described in https://hexdocs.pm/elixir/Process.html#info/2
foo@host> Node.spawn(node, fn -> IO.puts inspect Process.info(pid, :backtrace) end)

# Stop etop
foo@host> Node.spawn(node, fn -> :etop.stop end)

Also, if you have the required libs available you can do a :observer.start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment