From 8ff1e44cebf3aee09969a9324c04074ba87f10b9 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 14 Apr 2019 07:21:04 -0600 Subject: add dist name and cookie to ERL_FLAGS for nodetool (#712) * remove deprecated hex field from .app.src * start nodetool dist node in erl flags --- priv/templates/extended_bin | 20 +++++++++++++------- priv/templates/nodetool | 15 +++++++++++---- src/relx.app.src | 18 ++++++++---------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index cfeb859..a4cba4a 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -189,16 +189,22 @@ relx_gen_id() { relx_nodetool() { command="$1"; shift + # Generate a unique id used to allow multiple nodetool calls to the + # same node transparently + nodetool_id="maint$(relx_gen_id)-${NAME}" + if [ -z "${START_EPMD}" ]; then - ERL_FLAGS="${ERL_FLAGS} ${MAYBE_DIST_ARGS}" "$ERTS_DIR/bin/escript" \ - "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \ - -setcookie "$COOKIE" "$command" $@ + ERL_FLAGS="${ERL_FLAGS} ${MAYBE_DIST_ARGS} ${NAME_TYPE} $nodetool_id -setcookie ${COOKIE}" \ + "$ERTS_DIR/bin/escript" \ + "$ROOTDIR/bin/nodetool" \ + "$NAME_TYPE" "$NAME" \ + "$command" $@ else - ERL_FLAGS="${ERL_FLAGS} ${MAYBE_DIST_ARGS}" "$ERTS_DIR/bin/escript" \ - "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \ - $START_EPMD -setcookie "$COOKIE" "$command" $@ + ERL_FLAGS="${ERL_FLAGS} ${MAYBE_DIST_ARGS} ${NAME_TYPE} $nodetool_id -setcookie ${COOKIE}" \ + "$ERTS_DIR/bin/escript" \ + "$ROOTDIR/bin/nodetool" \ + $START_EPMD "$NAME_TYPE" "$NAME" "$command" $@ fi - } # Run an escript in the node's environment diff --git a/priv/templates/nodetool b/priv/templates/nodetool index 62fa02e..9e24f32 100644 --- a/priv/templates/nodetool +++ b/priv/templates/nodetool @@ -96,16 +96,23 @@ process_args(["-setcookie", Cookie | Rest], Acc, TargetNode, StartEpmd) -> process_args(["-start_epmd", StartEpmd | Rest], Acc, TargetNode, _StartEpmd) -> process_args(Rest, Acc, TargetNode, list_to_atom(StartEpmd)); process_args(["-name", TargetName | Rest], Acc, _, StartEpmd) -> - ThisNode = append_node_suffix(TargetName, "_maint_"), - {ok, _} = net_kernel:start([ThisNode, longnames]), + maybe_start_node(TargetName, longnames), process_args(Rest, Acc, nodename(TargetName), StartEpmd); process_args(["-sname", TargetName | Rest], Acc, _, StartEpmd) -> - ThisNode = append_node_suffix(TargetName, "_maint_"), - {ok, _} = net_kernel:start([ThisNode, shortnames]), + maybe_start_node(TargetName, shortnames), process_args(Rest, Acc, nodename(TargetName), StartEpmd); process_args([Arg | Rest], Acc, Opts, StartEpmd) -> process_args(Rest, [Arg | Acc], Opts, StartEpmd). +maybe_start_node(TargetName, Names) -> + case erlang:node() of + 'nonode@nohost' -> + ThisNode = append_node_suffix(TargetName, "_maint_"), + {ok, _} = net_kernel:start([ThisNode, Names]); + _ -> + ok + end. + start_epmd(true) -> [] = os:cmd("\"" ++ epmd_path() ++ "\" -daemon"), ok; diff --git a/src/relx.app.src b/src/relx.app.src index c8915d5..c845982 100644 --- a/src/relx.app.src +++ b/src/relx.app.src @@ -1,11 +1,9 @@ {application,relx, - [{description,"Release assembler for Erlang/OTP Releases"}, - {vsn,"git"}, - {modules,[]}, - {registered,[]}, - {applications,[kernel,stdlib,getopt,erlware_commons,bbmustache, - providers]}, - {maintainers,["Eric Merritt","Tristan Sloughter", - "Jordan Wilberding"]}, - {licenses,["Apache"]}, - {links,[{"Github","https://github.com/erlware/relx"}]}]}. + [{description,"Release assembler for Erlang/OTP Releases"}, + {vsn,"git"}, + {modules,[]}, + {registered,[]}, + {applications,[kernel,stdlib,getopt,erlware_commons,bbmustache, + providers]}, + {licenses,["Apache"]}, + {links,[{"Github","https://github.com/erlware/relx"}]}]}. -- cgit v1.2.3