Skip to content

Commit

Permalink
Merge pull request #4262 from esl/hotfix-commit-hash
Browse files Browse the repository at this point in the history
Make commit hash in system status fail-safe
  • Loading branch information
JanuszJakubiec committed Apr 11, 2024
2 parents 50c5fe6 + 1978e2d commit 616b692
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/mongoose_server_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set_loglevel(Level) ->
{invalid_level, io_lib:format("Log level ~p does not exist.", [Level])}
end.

-spec status() -> {ok, {boolean(), iolist(), iolist(), iolist()}}.
-spec status() -> {ok, {boolean(), iolist(), iolist(), iodata()}}.
status() ->
{InternalStatus, ProvidedStatus} = init:get_status(),
String1 = io_lib:format("The node ~p is ~p. Status: ~p.",
Expand All @@ -28,13 +28,17 @@ status() ->
{false, String1 ++ " MongooseIM is not running in that node.",
"MongooseIM is not running in that node", "MongooseIM is not running in that node"};
{value, {_, _, Version}} ->
[Number | Rest] = string:tokens(Version, "-"),
{true,
String1 ++ io_lib:format(" MongooseIM ~s is running in that node.", [Version]),
lists:nth(1, string:tokens(Version, "-")),
string:slice(lists:nth(3, string:tokens(Version, "-")), 1)}
Number,
get_commit_hash(Rest)}
end,
{ok, Result}.

get_commit_hash([_, "g" ++ Hash]) -> Hash;
get_commit_hash(_) -> <<>>.

-spec get_cookie() -> {ok, iolist()}.
get_cookie() ->
{ok, atom_to_list(erlang:get_cookie())}.
Expand Down

0 comments on commit 616b692

Please sign in to comment.