rabbit_runtime: Improve get_erl_path/0

[Why]
The previous implementation assumed that ERTS was in the Erlang root
dir. This is true for a standard Erlang install. However, it's not the
case of an Erlang release that does not include the runtime.

[How]
The bin directory (`bindir`) is already available as an argument to
init. We can simply query it and use the value as is.
This commit is contained in:
Jean-Sébastien Pédron 2023-11-18 16:27:17 +01:00
parent 0ea9395986
commit fdbf0ef2b2
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 3 additions and 4 deletions

View File

@ -56,11 +56,10 @@ msacc_stats(TimeInMs) ->
% get the full path to the erl executable used to start this VM
-spec get_erl_path() -> file:filename_all().
get_erl_path() ->
ERTSDir = rabbit_misc:format("erts-~ts", [erlang:system_info(version)]),
Bin = filename:join([code:root_dir(), ERTSDir, "bin"]),
{ok, [[BinDir]]} = init:get_argument(bindir),
case os:type() of
{win32, _} ->
filename:join(Bin, "erl.exe");
filename:join(BinDir, "erl.exe");
_ ->
filename:join(Bin, "erl")
filename:join(BinDir, "erl")
end.