Merge pull request #8662 from lafirest/fix/health_check_api
fix(mgmt): remove the `/api/v5` prefix of status API
This commit is contained in:
commit
38c771b581
|
@ -194,7 +194,7 @@ jobs:
|
|||
./emqx/bin/emqx start || cat emqx/log/erlang.log.1
|
||||
ready='no'
|
||||
for i in {1..18}; do
|
||||
if curl -fs 127.0.0.1:18083/api/v5/status > /dev/null; then
|
||||
if curl -fs 127.0.0.1:18083/status > /dev/null; then
|
||||
ready='yes'
|
||||
break
|
||||
fi
|
||||
|
|
|
@ -178,7 +178,7 @@ jobs:
|
|||
./emqx/bin/emqx start || cat emqx/log/erlang.log.1
|
||||
ready='no'
|
||||
for i in {1..30}; do
|
||||
if curl -fs 127.0.0.1:18083/api/v5/status > /dev/null; then
|
||||
if curl -fs 127.0.0.1:18083/status > /dev/null; then
|
||||
ready='yes'
|
||||
break
|
||||
fi
|
||||
|
|
|
@ -73,6 +73,7 @@ start_listeners(Listeners) ->
|
|||
Dispatch = [
|
||||
{"/", cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}},
|
||||
{"/static/[...]", cowboy_static, {priv_dir, emqx_dashboard, "www/static"}},
|
||||
{emqx_mgmt_api_status:path(), emqx_mgmt_api_status, []},
|
||||
{?BASE_PATH ++ "/[...]", emqx_dashboard_bad_api, []},
|
||||
{'_', cowboy_static, {priv_file, emqx_dashboard, "www/index.html"}}
|
||||
],
|
||||
|
|
|
@ -14,55 +14,25 @@
|
|||
%% limitations under the License.
|
||||
%%--------------------------------------------------------------------
|
||||
-module(emqx_mgmt_api_status).
|
||||
%% API
|
||||
-behaviour(minirest_api).
|
||||
|
||||
-export([
|
||||
api_spec/0,
|
||||
paths/0,
|
||||
schema/1
|
||||
init/2,
|
||||
path/0
|
||||
]).
|
||||
|
||||
-export([running_status/2]).
|
||||
path() ->
|
||||
"/status".
|
||||
|
||||
api_spec() ->
|
||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||
|
||||
paths() ->
|
||||
["/status"].
|
||||
|
||||
schema("/status") ->
|
||||
#{
|
||||
'operationId' => running_status,
|
||||
get =>
|
||||
#{
|
||||
description => <<"Node running status">>,
|
||||
tags => [<<"Status">>],
|
||||
security => [],
|
||||
responses =>
|
||||
#{
|
||||
200 =>
|
||||
#{
|
||||
description => <<"Node is running">>,
|
||||
content =>
|
||||
#{
|
||||
'text/plain' =>
|
||||
#{
|
||||
schema => #{type => string},
|
||||
example =>
|
||||
<<"Node emqx@127.0.0.1 is started\nemqx is running">>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.
|
||||
init(Req0, State) ->
|
||||
{Code, Headers, Body} = running_status(),
|
||||
Req = cowboy_req:reply(Code, Headers, Body, Req0),
|
||||
{ok, Req, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% API Handler funcs
|
||||
%%--------------------------------------------------------------------
|
||||
|
||||
running_status(get, _Params) ->
|
||||
running_status() ->
|
||||
BrokerStatus =
|
||||
case emqx:is_running() of
|
||||
true ->
|
||||
|
|
|
@ -31,7 +31,7 @@ end_per_suite(_) ->
|
|||
emqx_mgmt_api_test_util:end_suite().
|
||||
|
||||
t_status(_Config) ->
|
||||
Path = emqx_mgmt_api_test_util:api_path(["status"]),
|
||||
Path = emqx_mgmt_api_test_util:api_path_without_base_path(["/status"]),
|
||||
Status = io_lib:format("Node ~ts is ~ts~nemqx is ~ts", [node(), started, running]),
|
||||
{ok, Status} = emqx_mgmt_api_test_util:request_api(get, Path),
|
||||
ok.
|
||||
|
|
|
@ -110,6 +110,9 @@ build_http_header(X) ->
|
|||
api_path(Parts) ->
|
||||
?SERVER ++ filename:join([?BASE_PATH | Parts]).
|
||||
|
||||
api_path_without_base_path(Parts) ->
|
||||
?SERVER ++ filename:join([Parts]).
|
||||
|
||||
%% Usage:
|
||||
%% upload_request(<<"site.com/api/upload">>, <<"path/to/file.png">>,
|
||||
%% <<"upload">>, <<"image/png">>, [], <<"some-token">>)
|
||||
|
|
|
@ -142,14 +142,14 @@ spec:
|
|||
{{- end }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/v5/status
|
||||
path: /status
|
||||
port: {{ .Values.emqxConfig.EMQX_DASHBOARD__LISTENER__HTTP | default 18083 }}
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/v5/status
|
||||
path: /status
|
||||
port: {{ .Values.emqxConfig.EMQX_DASHBOARD__LISTENER__HTTP | default 18083 }}
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 30
|
||||
|
|
|
@ -103,7 +103,7 @@ emqx_test(){
|
|||
exit 1
|
||||
fi
|
||||
IDLE_TIME=0
|
||||
while ! curl http://127.0.0.1:18083/api/v5/status >/dev/null 2>&1; do
|
||||
while ! curl http://127.0.0.1:18083/status >/dev/null 2>&1; do
|
||||
if [ $IDLE_TIME -gt 10 ]
|
||||
then
|
||||
echo "emqx running error"
|
||||
|
@ -197,7 +197,7 @@ EOF
|
|||
exit 1
|
||||
fi
|
||||
IDLE_TIME=0
|
||||
while ! curl http://127.0.0.1:18083/api/v5/status >/dev/null 2>&1; do
|
||||
while ! curl http://127.0.0.1:18083/status >/dev/null 2>&1; do
|
||||
if [ $IDLE_TIME -gt 10 ]
|
||||
then
|
||||
echo "emqx running error"
|
||||
|
|
Loading…
Reference in New Issue