Search code examples
erlangerlang-supervisorgen-server

Kill all gen_server by supervisor in Erlang


In Erlang, I have a supervisor (my_sup) module to starts and monitor the gen_server process (my_gen). When the my_gen is modified, compiled and loaded, I need to restart the application.

Is there any better way to kill all the process (gen_server) by the supervisor (my_sup) and restart the process (gen_server) again?


Solution

  • To fix this is to stop the child and restart it.

    Stop and reload the childs

    restart_pool() ->
        supervisor:terminate_child(?SEVER, ?WORKER),
        supervisor:restart_child(?SERVER, ?WORKER).