summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <klishinm@vmware.com>2023-04-24 21:44:51 +0400
committerGitHub <noreply@github.com>2023-04-24 21:44:51 +0400
commit26ebd5c061e5976f36a80e4deec164abe416c5c3 (patch)
treea8abc607bdcd48a2690441a7f8c94ddef5dc6467
parent5f62600fce6199c4e2da06c9bfdfb689eca8b2a6 (diff)
parent57cd750a1aa49f2387e4d912d1f10ca2131a6f87 (diff)
downloadrabbitmq-server-git-26ebd5c061e5976f36a80e4deec164abe416c5c3.tar.gz
Merge pull request #7970 from rabbitmq/mk-silence-remote-shell-dialyzer-on-otp-26
CLI: more OTP 26 compatibility for remote_shell
-rw-r--r--deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex36
1 files changed, 25 insertions, 11 deletions
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex
index 231b09c3ff..6ca0b30015 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex
@@ -7,6 +7,7 @@
defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do
@behaviour RabbitMQ.CLI.CommandBehaviour
@dialyzer :no_missing_calls
+ @dialyzer {:nowarn_function, [run: 2, start_shell_on_otp_26_plus: 1, start_shell_on_otp_25: 1]}
use RabbitMQ.CLI.Core.MergesNoDefaults
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
@@ -15,18 +16,9 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do
_ = :c.l(:shell)
if :erlang.function_exported(:shell, :start_interactive, 1) do
- :shell.start_interactive({node_name, :shell, :start, []})
- :timer.sleep(:infinity)
+ start_shell_on_otp_26_plus(node_name)
else
- _ = Supervisor.terminate_child(:kernel_sup, :user)
- Process.flag(:trap_exit, true)
- user_drv = :user_drv.start(['tty_sl -c -e', {node_name, :shell, :start, []}])
- Process.link(user_drv)
-
- receive do
- {'EXIT', _user_drv, _} ->
- {:ok, "Disconnected from #{node_name}."}
- end
+ start_shell_on_otp_25(node_name)
end
end
@@ -41,4 +33,26 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do
def banner(_, %{node: node_name}) do
"Starting an interactive Erlang shell on node #{node_name}... Press 'Ctrl+G' then 'q' to exit."
end
+
+ defp start_shell_on_otp_26_plus(node_name) do
+ case :shell.start_interactive({node_name, {:shell, :start, []}}) do
+ :ok -> :ok
+ {:error, :already_started} -> :ok
+ {error, _} -> {:error, {:badrpc, :nodedown}}
+ end
+
+ :timer.sleep(:infinity)
+ end
+
+ defp start_shell_on_otp_25(node_name) do
+ _ = Supervisor.terminate_child(:kernel_sup, :user)
+ Process.flag(:trap_exit, true)
+ user_drv = :user_drv.start(['tty_sl -c -e', {node_name, :shell, :start, []}])
+ Process.link(user_drv)
+
+ receive do
+ {'EXIT', _user_drv, _} ->
+ {:ok, "Disconnected from #{node_name}."}
+ end
+ end
end