otp icon indicating copy to clipboard operation
otp copied to clipboard

Add application:get_supervisor/1

Open josevalim opened this issue 3 years ago • 4 comments

It returns the Pid of the supervisor running at the root of the given application.

This allows tools for introspection and debugging to print supervision trees without relying on private APIs.

josevalim avatar May 30 '22 21:05 josevalim

CT Test Results

       2 files       65 suites   55m 25s :stopwatch: 1 322 tests 1 181 :heavy_check_mark: 140 :zzz: 1 :x: 1 477 runs  1 305 :heavy_check_mark: 171 :zzz: 1 :x:

For more details on these failures, see this check.

Results for commit 26237d26.

:recycle: This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

github-actions[bot] avatar May 30 '22 21:05 github-actions[bot]

@josevalim If you used the name application:get_root_process/1 the concept would be more general because it looks like there isn't a requirement for the root process to be a supervisor. It would also be helpful if an application:get_group_leader/1 function existed too (just a call to application_controller:get_master/1).

okeuday avatar May 30 '22 23:05 okeuday

I am almost sure it has to be a supervisor and part of the tooling assumes so. To quote the docs for the start/2 callback:

The function is to return {ok,Pid} or {ok,Pid,State}, where Pid is the pid of the top supervisor and State is any term.

in any case, I will be glad to change the name anytime. :)

josevalim avatar May 31 '22 06:05 josevalim

Maybe get_top_supervisor.

essen avatar May 31 '22 07:05 essen