From 60b6febaab72c5e8a09aed657723e56a5cc769b1 Mon Sep 17 00:00:00 2001 From: Sean Cribbs Date: Tue, 11 Nov 2014 09:29:00 -0600 Subject: [PATCH] Handle net_ticktime argument specially. Resolves RIAK-1281 `escript` does not process emulator/runtime arguments like `erl`, so you can't blindly pass an application environment setting on the command line. This meant that the `-kernel net_ticktime N` argument passed to nodetool was not functioning as intended and being treated as regular arguments, resulting in a crash. The net_ticktime setting is also a sensitive setting and should likely be set before the Erlang distribution is started. I can only assume that the original author that added it had intended for it to be loaded by the application_controller, as `erl` does. Therefore, this change handles net_ticktime specially in nodetool:process_args/3 and puts it as the first argument to the script so that it is set first. --- priv/base/env.sh | 2 +- priv/base/nodetool | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/priv/base/env.sh b/priv/base/env.sh index 53704fc..bcaf475 100755 --- a/priv/base/env.sh +++ b/priv/base/env.sh @@ -117,7 +117,7 @@ APP_VSN=${START_ERL#* } ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin # Setup command to control the node -NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG $NET_TICKTIME_ARG" +NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NET_TICKTIME_ARG $NAME_ARG $COOKIE_ARG" NODETOOL_LITE="$ERTS_PATH/escript $ERTS_PATH/nodetool" diff --git a/priv/base/nodetool b/priv/base/nodetool index 0e95609..65c2092 100755 --- a/priv/base/nodetool +++ b/priv/base/nodetool @@ -116,6 +116,9 @@ main(Args) -> process_args([], Acc, TargetNode) -> {lists:reverse(Acc), TargetNode}; +process_args(["-kernel", "net_ticktime", Value | Rest], Acc, TargetNode) -> + application:set_env(kernel, net_ticktime, list_to_integer(Value)), + process_args(Rest, Acc, TargetNode); process_args(["-setcookie", Cookie | Rest], Acc, TargetNode) -> erlang:set_cookie(node(), list_to_atom(Cookie)), process_args(Rest, Acc, TargetNode);