From 4ea93cce5bab132818d42248ecfd16d8ab8a5c10 Mon Sep 17 00:00:00 2001 From: Luis Rascao Date: Thu, 20 Jul 2017 22:46:19 +0100 Subject: Don't fail status script command if empty --- priv/templates/extended_bin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index ed68748..71dd858 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -596,7 +596,7 @@ case "$1" in exit 1 fi - [ "$SCRIPT_DIR/$STATUS_HOOK" ] && . "$SCRIPT_DIR/$STATUS_HOOK" $@ + [ ! -z "${STATUS_HOOK}" ] && [ "$SCRIPT_DIR/$STATUS_HOOK" ] && . "$SCRIPT_DIR/$STATUS_HOOK" $@ ;; help) if [ -z "$2" ]; then -- cgit v1.2.3 From 2ba5ec449413a82ea3d6b9bdd268506b25ef368c Mon Sep 17 00:00:00 2001 From: Luis Rascao Date: Mon, 24 Jul 2017 23:21:11 +0100 Subject: Don't use builtin status hook as default Let people define their own when they want to. --- src/rlx_prv_assembler.erl | 2 +- test/rlx_extended_bin_SUITE.erl | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index 278756d..475869c 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -399,7 +399,7 @@ write_bin_file(State, Release, OutputDir, RelDir) -> Hooks = expand_hooks(BinDir, rlx_state:get(State, extended_start_script_hooks, - [{status, [builtin_status]}]), + []), State), extended_bin_file_contents(OsFamily, RelName, RelVsn, rlx_release:erts(Release), ErlOpts, diff --git a/test/rlx_extended_bin_SUITE.erl b/test/rlx_extended_bin_SUITE.erl index c049209..a9a7df7 100644 --- a/test/rlx_extended_bin_SUITE.erl +++ b/test/rlx_extended_bin_SUITE.erl @@ -1344,13 +1344,7 @@ builtin_status_script(Config) -> timer:sleep(2000), {ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])), %% write the status to a file - {ok, StatusStr} = sh(filename:join([OutputDir, "foo", "bin", "foo status"])), - ec_file:write(filename:join([OutputDir, "status.txt"]), - StatusStr ++ ".\n"), - os:cmd(filename:join([OutputDir, "foo", "bin", "foo stop"])), - {ok, [Status]} = file:consult(filename:join([OutputDir, "status.txt"])), - Apps = lists:map(fun({App, _, _}) -> App end, Status), - {ok, [goal_app, kernel, stdlib] = lists:sort(Apps)}. + {ok, ""} = sh(filename:join([OutputDir, "foo", "bin", "foo status"])). custom_status_script(Config) -> LibDir1 = proplists:get_value(lib1, Config), -- cgit v1.2.3 From 25196f4b994df5364eb060bff8418a0154622ed4 Mon Sep 17 00:00:00 2001 From: bitnitdit Date: Mon, 11 Sep 2017 20:57:17 +0800 Subject: Prevent .erlang from prepending string to the erl root dir Any output string from .erlang to stdout will be prepend to code:root_dir(), so it will cause the retrieved dir incorrect. The fix is to start erl with the no_dot_erlang boot file. --- priv/templates/bin | 2 +- priv/templates/bin_windows | 2 +- priv/templates/extended_bin | 2 +- priv/templates/extended_bin_windows | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/priv/templates/bin b/priv/templates/bin index 8bb6890..523b88d 100755 --- a/priv/templates/bin +++ b/priv/templates/bin @@ -22,7 +22,7 @@ find_erts_dir() { else __erl="$(which erl)" code="io:format(\"~s\", [code:root_dir()]), halt()." - __erl_root="$("$__erl" -noshell -eval "$code")" + __erl_root="$("$__erl" -boot no_dot_erlang -noshell -eval "$code")" ERTS_DIR="$__erl_root/erts-$ERTS_VSN" ROOTDIR="$__erl_root" fi diff --git a/priv/templates/bin_windows b/priv/templates/bin_windows index e66049e..b3ce796 100644 --- a/priv/templates/bin_windows +++ b/priv/templates/bin_windows @@ -60,7 +60,7 @@ cd %rootdir% @for /f "delims=" %%i in ('where erl') do ( set erl=%%i ) -@set dir_cmd="%erl%" -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop +@set dir_cmd="%erl%" -boot no_dot_erlang -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop @for /f "delims=" %%i in ('%%dir_cmd%%') do ( set erl_root=%%i ) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 71dd858..a48a917 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -120,7 +120,7 @@ find_erts_dir() { else __erl="$(which erl)" code="io:format(\"~s\", [code:root_dir()]), halt()." - __erl_root="$("$__erl" -noshell -eval "$code")" + __erl_root="$("$__erl" -boot no_dot_erlang -noshell -eval "$code")" ERTS_DIR="$__erl_root/erts-$ERTS_VSN" ROOTDIR="$__erl_root" fi diff --git a/priv/templates/extended_bin_windows b/priv/templates/extended_bin_windows index 139edaa..85c57f4 100644 --- a/priv/templates/extended_bin_windows +++ b/priv/templates/extended_bin_windows @@ -98,7 +98,7 @@ @for /f "delims=" %%i in ('where erl') do @( set erl=%%i ) -@set dir_cmd="%erl%" -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop +@set dir_cmd="%erl%" -boot no_dot_erlang -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop @for /f "delims=" %%i in ('%%dir_cmd%%') do @( set erl_root=%%i ) -- cgit v1.2.3 From 76f3ab093ded13fc687356968169be301c1e65d0 Mon Sep 17 00:00:00 2001 From: Jan Uhlig Date: Tue, 19 Sep 2017 16:58:09 +0200 Subject: PIPE_DIR handling As mentioned in the (closed) issue #127, the default pipe directory is not multi-user friendly. When running multiple relx-generated releases as different users, the first to be started will create the /tmp/erl_pipes directory, which the ones starting after that cannot create their pipe dirs in. The ticket mentions that this should be fixed by #154, but I cannot see how this is supposed to solve the issue. Right now, the only way I see is to use prefix the start command with env PIPE_DIR=/some/other/dir/, which is quite cumbersome. This change will work exactly as before when PIPE_DIR is explicitly set. In case PIPE_DIR is not set, however, it will first attempt to create the parent dir /tmp/erl_pipes with mode 1777, which should enable releases being run as other users to create their pipe dirs. --- priv/templates/extended_bin | 2 ++ 1 file changed, 2 insertions(+) diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index a48a917..2580dcc 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -325,6 +325,7 @@ RELX_CONFIG_PATH=$(check_replace_os_vars sys.config $RELX_CONFIG_PATH) # Make sure log directory exists mkdir -p "$RUNNER_LOG_DIR" +test -z "$PIPE_DIR" && PIPE_BASE_DIR='/tmp/erl_pipes/' PIPE_DIR="${PIPE_DIR:-/tmp/erl_pipes/$NAME/}" # Extract the target cookie @@ -378,6 +379,7 @@ case "$1" in HEART_COMMAND="$RELEASE_ROOT_DIR/bin/$REL_NAME $CMD" export HEART_COMMAND + test -z "$PIPE_BASE_DIR" || mkdir -m 1777 -p "$PIPE_BASE_DIR" mkdir -p "$PIPE_DIR" relx_run_hooks "$PRE_START_HOOKS" -- cgit v1.2.3