Controlling GenServers on a remote server

  1. If GenServer crashes on a server, how will I be notified? How to look after it?

  2. Is there any way to see all GenServers running on a remote server in a web application and their state? Say, I’ve connected to my remote application and how would I get inside it and see what’s running, their states and what-not?

  3. What’s the name of a tool which shows Elixir threads, what’s running, GenServers and other useful information?

  1. I think it’s up to your logic or 3d party tools.
  2. Basically you will need a pid of a gen server to see it’s state and other process info.
    you can use :sys.get_state or :sys.get_status to see the state of the process
  3. I believe there are several such tools but one that usually comes precompiled with Erlang is :observer, you can ran it with :observer.start()

Thats what a Supervisor is meant for. They restart your various processes (not only GenServers) after they crashed. You as a person do not wan’t to get notified! Your inbox will probably overflow after you catched up the idioms of “fail fast” and “let it crash”.

You can use the usual tools for process discovery. You can’t see though what kind a process is, since the BEAM doesn’t do anything special with a Supervisor or a GenServer, they are just bare processes which implement some protocol.

Perhaps you can use some kind of registry, where processes register and unregister theirself. You can store metadata there as well.

For a rough overview you can also use erlangs :observer module, or perhaps you can make use of :wobserver application, which originally was planned as a web version of :observer but seems to have grown to be far more than that from the screenshots on github.

1 Like