fix(dashboard): display full Erlang/OTP version

This commit is contained in:
Zaiming Shi 2021-04-30 11:45:36 +02:00 committed by Zaiming (Stone) Shi
parent 05835f2fab
commit 171933301a
2 changed files with 13 additions and 4 deletions

View File

@ -553,7 +553,7 @@ rpc_call(Node, Fun, Args) ->
end.
otp_rel() ->
lists:concat(["R", erlang:system_info(otp_release), "/", erlang:system_info(version)]).
lists:concat([emqx_vm:get_otp_version(), "/", erlang:system_info(version)]).
check_row_limit(Tables) ->
check_row_limit(Tables, max_row_limit()).

View File

@ -369,16 +369,17 @@ compat_windows(Fun) ->
end.
%% @doc Return on which Eralng/OTP the current vm is running.
%% NOTE: This API reads a file, do not use it in critical code paths.
get_otp_version() ->
string:trim(binary_to_list(read_otp_version())).
parse_built_on(read_otp_version()).
read_otp_version() ->
ReleasesDir = filename:join([code:root_dir(), "releases"]),
Filename = filename:join([ReleasesDir, emqx_app:get_release(), "BUILT_ON"]),
case file:read_file(Filename) of
{ok, Vsn} ->
{ok, BuiltOn} ->
%% running on EQM X release
Vsn;
BuiltOn;
{error, enoent} ->
%% running tests etc.
OtpMajor = erlang:system_info(otp_release),
@ -386,3 +387,11 @@ read_otp_version() ->
{ok, Vsn} = file:read_file(OtpVsnFile),
Vsn
end.
parse_built_on(BuiltOn) ->
case binary:split(BuiltOn, <<"-">>, [global]) of
[Vsn, <<"emqx">>, N | _] ->
binary_to_list(Vsn) ++ "-emqx-" ++ binary_to_list(N);
[Vsn | _] ->
string:trim(binary_to_list(Vsn))
end.