From f0e51cea4d01d9657f1ea0ccde2f3326faaf36de Mon Sep 17 00:00:00 2001 From: Stanislav Vishnevskiy Date: Tue, 27 Sep 2016 22:56:29 -0700 Subject: [PATCH 1/3] Optional code change for special processes. --- lib/mix/lib/releases/appups.ex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/mix/lib/releases/appups.ex b/lib/mix/lib/releases/appups.ex index 9e59a35d..a7900a2c 100644 --- a/lib/mix/lib/releases/appups.ex +++ b/lib/mix/lib/releases/appups.ex @@ -112,7 +112,7 @@ defmodule Mix.Releases.Appup do exports = beam_exports(v1_file) imports = beam_imports(v2_file) is_supervisor = is_supervisor?(attributes) - is_special_proc = is_special_process?(exports) + is_special_proc = is_special_process?(attributes, exports) depends_on = imports |> Enum.map(fn {m,_f,_a} -> m end) |> Enum.uniq @@ -134,9 +134,13 @@ defmodule Mix.Releases.Appup do exports end - defp is_special_process?(exports) do - Keyword.get(exports, :system_code_change) == 4 || - Keyword.get(exports, :code_change) == 3 + defp is_special_process?(attributes, exports) do + if attributes[:distillery_code_change] == [false] do + false + else + Keyword.get(exports, :system_code_change) == 4 || + Keyword.get(exports, :code_change) == 3 + end end defp is_supervisor?(attributes) do From ce98b51da854c478bc27bef8c962b3522b840ce4 Mon Sep 17 00:00:00 2001 From: Stanislav Vishnevskiy Date: Tue, 27 Sep 2016 23:13:10 -0700 Subject: [PATCH 2/3] Use v2 file for generation. --- lib/mix/lib/releases/appups.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mix/lib/releases/appups.ex b/lib/mix/lib/releases/appups.ex index a7900a2c..91f89833 100644 --- a/lib/mix/lib/releases/appups.ex +++ b/lib/mix/lib/releases/appups.ex @@ -106,10 +106,10 @@ defmodule Mix.Releases.Appup do defp generate_instruction(:added, file), do: {:add_module, module_name(file)} defp generate_instruction(:deleted, file), do: {:delete_module, module_name(file)} - defp generate_instruction(:changed, {v1_file, v2_file}) do - module_name = module_name(v1_file) - attributes = beam_attributes(v1_file) - exports = beam_exports(v1_file) + defp generate_instruction(:changed, {_v1_file, v2_file}) do + module_name = module_name(v2_file) + attributes = beam_attributes(v2_file) + exports = beam_exports(v2_file) imports = beam_imports(v2_file) is_supervisor = is_supervisor?(attributes) is_special_proc = is_special_process?(attributes, exports) From bbf7f1871553465eb21ef8ed5e2ace3308d79683 Mon Sep 17 00:00:00 2001 From: Stanislav Vishnevskiy Date: Thu, 29 Sep 2016 00:32:46 -0700 Subject: [PATCH 3/3] Don't use _get_code_paths --- priv/templates/boot.eex | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/priv/templates/boot.eex b/priv/templates/boot.eex index 749ed220..9bc78bc4 100644 --- a/priv/templates/boot.eex +++ b/priv/templates/boot.eex @@ -20,7 +20,7 @@ my_readlink_f() { cd $(dirname "$TARGET_FILE") TARGET_FILE=$(basename "$TARGET_FILE") done - # Compute the canonicalized name by finding the physical path + # Compute the canonicalized name by finding the physical path # for the directory we're in and appending the target file. PHYS_DIR=$(pwd -P) RESULT="$PHYS_DIR/$TARGET_FILE" @@ -132,11 +132,6 @@ _detect_erts_vsn() { "$BINDIR/erl" -boot start_clean -eval 'Ver = erlang:system_info(version), io:format("~s~n", [Ver]), halt()' -noshell } -# Private. Gets a list of code paths for this release -_get_code_paths() { - "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/release_utils.escript" "get_code_paths" "$ROOTDIR" "$ERTS_DIR" "$REL_DIR" "$REL_NAME" -} - # Private. For setting ERTS_DIR and ROOTDIR _find_erts_dir() { __erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN" @@ -169,10 +164,9 @@ _rem_sh() { -kernel net_ticktime $TICKTIME \ "$NAME_TYPE" "$id" -remsh "$NAME" -setcookie "$COOKIE" else - __code_paths=$(_get_code_paths) exec "$BINDIR/erl" \ + -pa "$ROOTDIR"/lib/*/ebin \ -pa "$CONSOLIDATED_DIR" \ - ${__code_paths} \ -hidden -noshell \ -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \ -kernel net_ticktime $TICKTIME \ @@ -507,15 +501,14 @@ case "$1" in # the console will crash with no TTY attached [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK" - __code_paths=$(_get_code_paths) # Build an array of arguments to pass to exec later on # Build it here because this command will be used for logging. set -- "$BINDIR/erlexec" \ -boot "$BOOTFILE" \ -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \ -env ERL_LIBS "$REL_LIB_DIR" \ + -pa "$ROOTDIR"/lib/*/ebin \ -pa "$CONSOLIDATED_DIR" \ - ${__code_paths} \ -args_file "$VMARGS_PATH" \ -config "$SYS_CONFIG_PATH" \ -mode "$CODE_LOADING_MODE" \ @@ -630,14 +623,13 @@ case "$1" in ARGS="$@" # Build arguments for erlexec - __code_paths=$(_get_code_paths) set -- "$ERL_OPTS" [ "$SYS_CONFIG_PATH" ] && set -- "$@" -config "$SYS_CONFIG_PATH" set -- "$@" -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" set -- "$@" -noshell set -- "$@" -boot start_clean + set -- "$@" -pa "$ROOTDIR"/lib/*/ebin set -- "$@" -pa "$CONSOLIDATED_DIR" - set -- "$@" ${__code_paths} set -- "$@" -s "$MODULE" "$FUNCTION"