Search code examples
processelixirerlang-supervisor

supervising a number of existing processes


In elixir, is there any way of supervising existing processes? Like

Supervisor.supervise_processes([pid1,pid2,...,pidn],strategy: :simple_one_for_one)

Solution

  • No, you can't. Supervisors take specifications of processes, not processes, so they can reuse the specification over and over again to restart the process. Clearly, a process id alone is not enough data to do a restart when it dies.

    Having said that - you can monitor a process and do whatever you want when you get a signal that it died.