Skip to content

Commit

Permalink
add dist name and cookie to ERL_FLAGS for nodetool (#712)
Browse files Browse the repository at this point in the history
* remove deprecated hex field from .app.src

* start nodetool dist node in erl flags
  • Loading branch information
tsloughter authored Apr 14, 2019
1 parent 4825a49 commit 8ff1e44
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
20 changes: 13 additions & 7 deletions priv/templates/extended_bin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions priv/templates/nodetool
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 8 additions & 10 deletions src/relx.app.src
Original file line number Diff line number Diff line change
@@ -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"}]}]}.

0 comments on commit 8ff1e44

Please sign in to comment.