diff --git a/big_tests/tests/graphql_server_SUITE.erl b/big_tests/tests/graphql_server_SUITE.erl index a068d28a89f..b48c53a5fbe 100644 --- a/big_tests/tests/graphql_server_SUITE.erl +++ b/big_tests/tests/graphql_server_SUITE.erl @@ -143,7 +143,8 @@ get_status_test(Config) -> Result = get_ok_value([data, server, status], get_status(Config)), ?assertEqual(<<"RUNNING">>, maps:get(<<"statusCode">>, Result)), ?assert(is_binary(maps:get(<<"message">>, Result))), - ?assert(is_binary(maps:get(<<"version">>, Result))). + ?assert(is_binary(maps:get(<<"version">>, Result))), + ?assert(is_binary(maps:get(<<"commitHash">>, Result))). join_successful(Config) -> @@ -292,7 +293,7 @@ ensure_node_started(Node) -> Timeout = timer:seconds(60), F = fun() -> case rpc(Node#{timeout => Timeout}, mongoose_server_api, status, []) of - {ok, {true, _, _}} -> true; + {ok, {true, _, _, _}} -> true; _Other -> false end end, diff --git a/priv/graphql/schemas/admin/server.gql b/priv/graphql/schemas/admin/server.gql index 741ea84e353..19491401e83 100644 --- a/priv/graphql/schemas/admin/server.gql +++ b/priv/graphql/schemas/admin/server.gql @@ -48,6 +48,8 @@ type Status { message: String "MongooseIM version" version: String + "The hash of the commit that MongooseIM is running" + commitHash: String } "Specifies status of the server" diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl index d52e8c07478..899e71ae2cf 100644 --- a/src/ejabberd_admin.erl +++ b/src/ejabberd_admin.erl @@ -46,7 +46,7 @@ %%% -spec status() -> {ok, {boolean(), iolist()}}. status() -> - {ok, {Status, Message, _}} = mongoose_server_api:status(), + {ok, {Status, Message, _, _}} = mongoose_server_api:status(), {ok, {Status, Message}}. %%% diff --git a/src/graphql/admin/mongoose_graphql_server_admin_query.erl b/src/graphql/admin/mongoose_graphql_server_admin_query.erl index eb6e84b6d99..e994800e82e 100644 --- a/src/graphql/admin/mongoose_graphql_server_admin_query.erl +++ b/src/graphql/admin/mongoose_graphql_server_admin_query.erl @@ -8,9 +8,9 @@ -include("../mongoose_graphql_types.hrl"). execute(_Ctx, server, <<"status">>, _) -> - {ok, {Status, Message, Version}} = mongoose_server_api:status(), + {ok, {Status, Message, Version, CommitHash}} = mongoose_server_api:status(), {ok, #{<<"statusCode">> => status_code(Status), <<"message">> => Message, - <<"version">> => Version}}; + <<"version">> => Version, <<"commitHash">> => CommitHash}}; execute(_Ctx, server, <<"getLoglevel">>, _) -> mongoose_server_api:get_loglevel(); execute(_Ctx, server, <<"getCookie">>, _) -> diff --git a/src/mongoose_server_api.erl b/src/mongoose_server_api.erl index 390ccac5b81..187a9a772dc 100644 --- a/src/mongoose_server_api.erl +++ b/src/mongoose_server_api.erl @@ -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()}}. +-spec status() -> {ok, {boolean(), iolist(), iolist(), iolist()}}. status() -> {InternalStatus, ProvidedStatus} = init:get_status(), String1 = io_lib:format("The node ~p is ~p. Status: ~p.", @@ -26,11 +26,12 @@ status() -> case lists:keysearch(mongooseim, 1, application:which_applications()) of false -> {false, String1 ++ " MongooseIM is not running in that node.", - "MongooseIM is not running in that node"}; + "MongooseIM is not running in that node", "MongooseIM is not running in that node"}; {value, {_, _, Version}} -> {true, String1 ++ io_lib:format(" MongooseIM ~s is running in that node.", [Version]), - lists:nth(1, string:split(Version, "-"))} + lists:nth(1, string:tokens(Version, "-")), + string:slice(lists:nth(3, string:tokens(Version, "-")), 1)} end, {ok, Result}.