aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_ctl.erl
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2015-12-08 11:25:26 +0100
committerPaweł Chmielowski <pchmielowski@process-one.net>2015-12-08 11:25:26 +0100
commit7a69dab5963b13953c5fb08fdb2b39635c1c8992 (patch)
treeff5576f3077c553c7e6fe14dfa4c3153af8e8fb0 /src/ejabberd_ctl.erl
parentmod_mam: Honor Message Processing Hints (XEP-0334) (diff)
Add ability to disable timeout for ejabberdctl command
Diffstat (limited to 'src/ejabberd_ctl.erl')
-rw-r--r--src/ejabberd_ctl.erl67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl
index ec916b32b..b0a1069d9 100644
--- a/src/ejabberd_ctl.erl
+++ b/src/ejabberd_ctl.erl
@@ -63,37 +63,40 @@
%%-----------------------------
start() ->
- case init:get_plain_arguments() of
- [SNode | Args] ->
- SNode1 = case string:tokens(SNode, "@") of
- [_Node, _Server] ->
- SNode;
- _ ->
- case net_kernel:longnames() of
- true ->
- lists:flatten([SNode, "@", inet_db:gethostname(),
- ".", inet_db:res_option(domain)]);
- false ->
- lists:flatten([SNode, "@", inet_db:gethostname()]);
- _ ->
- SNode
- end
- end,
- Node = list_to_atom(SNode1),
- Status = case rpc:call(Node, ?MODULE, process, [Args], 60000) of
- {badrpc, Reason} ->
- print("Failed RPC connection to the node ~p: ~p~n",
- [Node, Reason]),
- %% TODO: show minimal start help
- ?STATUS_BADRPC;
- S ->
- S
- end,
- halt(Status);
- _ ->
- print_usage(),
- halt(?STATUS_USAGE)
- end.
+ [SNode, Timeout, Args] = case init:get_plain_arguments() of
+ [SNode2, "--no-timeout" | Args2] ->
+ [SNode2, infinity, Args2];
+ [SNode3 | Args3] ->
+ [SNode3, 10000, Args3];
+ _ ->
+ print_usage(),
+ halt(?STATUS_USAGE)
+ end,
+ SNode1 = case string:tokens(SNode, "@") of
+ [_Node, _Server] ->
+ SNode;
+ _ ->
+ case net_kernel:longnames() of
+ true ->
+ lists:flatten([SNode, "@", inet_db:gethostname(),
+ ".", inet_db:res_option(domain)]);
+ false ->
+ lists:flatten([SNode, "@", inet_db:gethostname()]);
+ _ ->
+ SNode
+ end
+ end,
+ Node = list_to_atom(SNode1),
+ Status = case rpc:call(Node, ?MODULE, process, [Args], Timeout) of
+ {badrpc, Reason} ->
+ print("Failed RPC connection to the node ~p: ~p~n",
+ [Node, Reason]),
+ %% TODO: show minimal start help
+ ?STATUS_BADRPC;
+ S ->
+ S
+ end,
+ halt(Status).
init() ->
ets:new(ejabberd_ctl_cmds, [named_table, set, public]),
@@ -470,7 +473,7 @@ print_usage(HelpMode, MaxC, ShCode) ->
get_list_ctls(),
print(
- ["Usage: ", ?B("ejabberdctl"), " [--node ", ?U("nodename"), "] [--auth ",
+ ["Usage: ", ?B("ejabberdctl"), " [--no-timeout] [--node ", ?U("nodename"), "] [--auth ",
?U("user"), " ", ?U("host"), " ", ?U("password"), "] ",
?U("command"), " [", ?U("options"), "]\n"
"\n"