Search⌘ K
AI Features

Examine Running Processes and Stop the Supervisors

Explore how to use Elixir’s which_children and count_children functions to monitor running child processes under GenServer supervisors. Learn to identify idle processes and use Supervisor.stop to halt supervisors when necessary, helping you manage concurrency and system resources efficiently.

The which_children function

We can get more information about running child processes by using which_children/1. This function returns a list of tuples. Each tuple has four elements:

  • It contains the child process’s ID, which could be :undefined for dynamically started processes.

  • It contains the child process’s PID or the :restarting value when the process is in the middle of a restart.

  • It contains the process’s type, either :worker or :supervisor.

  • It also contains the module implementation, which ...