From 9b3f88aeeb25844decfa5d06fccf5c0e1e8c2e9b Mon Sep 17 00:00:00 2001 From: Serge Tupchii Date: Wed, 6 Sep 2023 12:33:07 +0300 Subject: [PATCH] feat(nodetool): print shutdown status messages while EMQX is stopping --- bin/nodetool | 17 ++++++++++++++++- changes/ce/fix-11567.en.md | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/nodetool b/bin/nodetool index 511ef8e28..3af3bd21a 100755 --- a/bin/nodetool +++ b/bin/nodetool @@ -87,7 +87,10 @@ do(Args) -> %% a "pong" io:format("pong\n"); ["stop"] -> - case rpc:call(TargetNode, emqx_machine, graceful_shutdown, [], ?SHUTDOWN_TIMEOUT_MS) of + Pid = start_shutdown_status(), + Res = rpc:call(TargetNode, emqx_machine, graceful_shutdown, [], ?SHUTDOWN_TIMEOUT_MS), + true = stop_shutdown_status(Pid), + case Res of ok -> ok; {badrpc, timeout} -> @@ -152,6 +155,18 @@ do(Args) -> end, net_kernel:stop(). +start_shutdown_status() -> + spawn_link(fun shutdown_status_loop/0). + +stop_shutdown_status(Pid) -> + true = unlink(Pid), + true = exit(Pid, stop). + +shutdown_status_loop() -> + timer:sleep(10_000), + io:format("EMQX is shutting down, please wait...\n", []), + shutdown_status_loop(). + parse_eval_args(Args) -> % shells may process args into more than one, and end up stripping % spaces, so this converts all of that to a single string to parse diff --git a/changes/ce/fix-11567.en.md b/changes/ce/fix-11567.en.md index 026674f69..c19db971b 100644 --- a/changes/ce/fix-11567.en.md +++ b/changes/ce/fix-11567.en.md @@ -1,3 +1,4 @@ Improve EMQX graceful shutdown (`emqx stop` command): - increase timeout from 1 to 2 minutes - print an error message if EMQX can't stop gracefully within the configured timeout +- print periodic status messages while EMQX is shutting down