forked from 2600hz/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[master] KAZOO-5578: update relx and change vm.args (2600hz#3907)
* KAZOO-5578: bump relx version to 3.23.0 to fix vm.args issue * KAZOO-5578: rewrite vm.args to a new file with node name temperoray patch kazoo bin generated by relx to rewrite vm.args to a new file with node name included on the file name. * KAZOO-5578: use another approach in relx bin to support include config `sys.config` file supports include from another config file, the catch is the the actual config file should be named excatly _sys.config_. Relx supports environment variable substitution in `vm.args` and `sys.config`. They added a multi node option which basically would replace env vars in (for example `vm.args`) file and save the result in `vm.NODE_NAME.args`. In no multi node situation it just substitute env vars to `vm.args` and would copy the the orignal file into` vm.args.orig`. First issue is exctracting `NAME_ARGS ("-s?name NODE_NAME")`, which is always uses vm.args (the file with substituted env vars) which is result of the previous run and contains the previous `NODE_NAME`, which means not honoring current `NODE_NAME` for commands of kazoo release script. In other hand, it turns out sup command is unhappy when it calls multiple times or simultaneously since `vm.args` is rewritten every time and could be ends up corrupted or missed. So removing `RELX_REPLACE_OS_VARS` could be a good solution since escript doesn't have node name and cookie options. This turns out to copy the ``".orig"`` files to the their env vars substituted ones. This commit contains a patch for the script to fix those issues. Other changes: * Remove `RELX_REPLACE_OS_VARS` from sup command script. * clean up `scripts/dev/kazoo.sh` * paramertize cookie in `vm.args` * KAZOO-5578: update relx.patch to remove +Bd argument and better logging * KAZOO-5578: ad RELX_MULTI_NODE to kazoo.sh
- Loading branch information
1 parent
b505bdb
commit bfad83c
Showing
8 changed files
with
116 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# The file to copy/symlink under /usr/bin or similar | ||
DEFAULT_REL='sup@`hostname -f`' | ||
|
||
if [[ ! -z "$KAZOO_ROOT" ]]; then | ||
DEFAULT_ROOT="$KAZOO_ROOT" | ||
elif [[ -d _rel/kazoo ]]; then | ||
DEFAULT_ROOT=_rel/kazoo | ||
DEFAULT_ROOT=${KAZOO_ROOT:-_rel/kazoo} | ||
if [ -d "$DEFAULT_ROOT/_rel/kazoo" ]; then | ||
DEFAULT_ROOT="$DEFAULT_ROOT" | ||
elif [ -d "$DEFAULT_ROOT/bin" ]; then | ||
DEFAULT_ROOT="$DEFAULT_ROOT" | ||
elif [ -d /opt/kazoo/_rel/kazoo ]; then | ||
DEFAULT_ROOT="/opt/kazoo/_rel/kazoo" | ||
elif [ -d /opt/kazoo/bin ]; then | ||
DEFAULT_ROOT="/opt/kazoo" | ||
else | ||
DEFAULT_ROOT=/opt/kazoo | ||
echo "Can't find Kazoo release root directory, is the release built?" | ||
exit -1 | ||
fi | ||
|
||
export NAME_ARG="-name ${DEFAULT_REL}" | ||
|
||
RELX_REPLACE_OS_VARS=true KZname="-name ${DEFAULT_REL}" "${DEFAULT_ROOT}"/bin/kazoo escript lib/sup-*/priv/sup.escript "$*" | ||
"${DEFAULT_ROOT}"/bin/kazoo escript lib/sup-*/priv/sup.escript "$*" | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@@ -259,12 +259,16 @@ | ||
else | ||
replace_os_vars "$IN_FILE_PATH" "$OUT_FILE_PATH" | ||
fi | ||
- else | ||
- # If vm.arg.orig or sys.config.orig is present then use that | ||
- if [ -f "$ORIG_FILE_PATH" ]; then | ||
- cp "$ORIG_FILE_PATH" "$OUT_FILE_PATH" | ||
- fi | ||
fi | ||
+ | ||
+ # If $RELX_REPLACE_OS_VARS is not set and vm.arg.orig or | ||
+ # sys.config.orig is present this means that env variable | ||
+ # substitution has occurred before and the result is | ||
+ # already saved to vm.args and sys.config in previous run. | ||
+ # This could happens for running escripts, etc... which | ||
+ # really doesn't need these files if the user doesn't want | ||
+ # vm.args to be written so often. | ||
+ | ||
echo $OUT_FILE_PATH | ||
} | ||
|
||
@@ -293,7 +297,12 @@ | ||
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH" | ||
ERTS_LIB_DIR="$(dirname "$ERTS_DIR")/lib" | ||
|
||
-VMARGS_PATH=$(add_path vm.args $VMARGS_PATH) | ||
+VMARGS_ORIG_PATH=$(add_path vm.args.orig) | ||
+if [ -f "$VMARGS_ORIG_PATH" ]; then | ||
+ VMARGS_PATH="$VMARGS_ORIG_PATH" | ||
+else | ||
+ VMARGS_PATH=$(add_path vm.args $VMARGS_PATH) | ||
+fi | ||
# Extract the target node name from node.args | ||
NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true) | ||
# Perform replacement of variables in ${NAME_ARG} | ||
@@ -515,7 +524,7 @@ | ||
else | ||
BOOTFILE="$REL_DIR/start" | ||
fi | ||
- FOREGROUNDOPTIONS="-noshell -noinput +Bd" | ||
+ FOREGROUNDOPTIONS="-noshell -noinput" | ||
;; | ||
console_clean) | ||
__code_paths=$(relx_get_code_paths) | ||
@@ -552,7 +561,7 @@ | ||
|
||
# Log the startup | ||
echo "$RELEASE_ROOT_DIR" | ||
- logger -t "$REL_NAME[$$]" "Starting up" | ||
+ logger -t "$REL_NAME[$$]" "Starting up $NAME ($REL_NAME-$REL_VSN - Erts $ERTS_VSN)" | ||
|
||
# Start the VM | ||
exec "$@" -- ${1+$ARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,47 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
if [ "$KAZOO_CONFIG" = "" ] | ||
then | ||
export KAZOO_CONFIG=$HOME/config.ini | ||
echo Using default config: $KAZOO_CONFIG | ||
# look for kazoo release root directory | ||
DEFAULT_ROOT=${KAZOO_ROOT:-_rel/kazoo} | ||
if [ -d "$DEFAULT_ROOT/_rel/kazoo" ]; then | ||
DEFAULT_ROOT="$DEFAULT_ROOT" | ||
elif [ -d "$DEFAULT_ROOT/bin" ]; then | ||
DEFAULT_ROOT="$DEFAULT_ROOT" | ||
elif [ -d /opt/kazoo/_rel/kazoo ]; then | ||
DEFAULT_ROOT="/opt/kazoo/_rel/kazoo" | ||
elif [ -d /opt/kazoo/bin ]; then | ||
DEFAULT_ROOT="/opt/kazoo" | ||
else | ||
echo "Can't find Kazoo release root directory, is the release built?" | ||
exit -1 | ||
fi | ||
echo "Release path: $DEFAULT_ROOT" | ||
|
||
if [ ! -f $KAZOO_CONFIG ]; then | ||
echo "Specified kazoo config doesn't exists, please provide readable kazoo config file" | ||
exit | ||
# look for kazoo config file path | ||
if [ -f "$KAZOO_CONFIG" ]; then | ||
KAZOO_CONFIG="$KAZOO_CONFIG" | ||
elif [ -f $HOME/config.ini ]; then | ||
KAZOO_CONFIG=$HOME/config.ini | ||
elif [ -f /etc/kazoo/config.ini ]; then | ||
KAZOO_CONFIG="/etc/kazoo/config.ini" | ||
elif [ -f /etc/kazoo/core/config.ini ]; then | ||
KAZOO_CONFIG="/etc/kazoo/core/config.ini" | ||
else | ||
echo "Kazoo config doesn't exists, please provide readable kazoo config file" | ||
exit -1 | ||
fi | ||
echo "Kazoo config file path: $KAZOO_CONFIG" | ||
|
||
if [ "$KAZOO_NODE" = "" ] | ||
then | ||
KAZOO_NODE=kazoo_apps@$(hostname) | ||
echo Using default node name: $KAZOO_NODE | ||
fi | ||
NODE_NAME=${NODE_NAME:-kazoo_apps@$(hostname -f)} | ||
echo "Node name: $NODE_NAME" | ||
|
||
COOKIE=${COOKIE:-"change_me"} | ||
echo "Cookie: $COOKIE" | ||
|
||
CMD=$1 | ||
if [ "$CMD" = "" ] | ||
then | ||
CMD=console | ||
if [ "$CMD" = "" ]; then | ||
CMD=console | ||
else | ||
shift | ||
shift | ||
fi | ||
|
||
RELX_REPLACE_OS_VARS=true KZname="-name $KAZOO_NODE" _rel/kazoo/bin/kazoo $CMD "$*" | ||
RELX_REPLACE_OS_VARS=true RELX_MULTI_NODE=true NODE_NAME="$NODE_NAME" COOKIE="$COOKIE" "$DEFAULT_ROOT"/bin/kazoo $CMD "$*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
#!/bin/bash | ||
KAZOO_NODE=${KAZOO_NODE:-kazoo_apps@$(hostname)} | ||
echo Connecting to node: $KAZOO_NODE | ||
|
||
IFS='@' read -r -a NH <<< "$KAZOO_NODE" | ||
NAME="${NH[0]}" | ||
|
||
RELX_REPLACE_OS_VARS=true KZname="-name $KAZOO_NODE" \ | ||
exec _rel/kazoo/bin/kazoo escript lib/sup-*/priv/sup.escript \ | ||
-n $NAME \ | ||
"$*" | ||
_rel/kazoo/bin/kazoo escript lib/sup-*/priv/sup.escript "$*" |