aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuis Rascao <[email protected]>2017-05-14 02:15:05 +0100
committerLuis Rascao <[email protected]>2017-05-15 17:27:56 +0100
commit82f6c94a4d8ef1cf2be0becc5816d0646e5a50cc (patch)
tree0859e7e9a796f69dd26ebc015c8c7b0ca9d5f199 /src
parentc1fa56db1ec4cc4aa6975f4efee0c189452a251d (diff)
downloadrelx-82f6c94a4d8ef1cf2be0becc5816d0646e5a50cc.tar.gz
relx-82f6c94a4d8ef1cf2be0becc5816d0646e5a50cc.tar.bz2
relx-82f6c94a4d8ef1cf2be0becc5816d0646e5a50cc.zip
Add custom status hook to extended script
Provide a status command to start script which, by default, runs a builtin hook that simply prints which applications are running in the node. This hook can then be customized to print whatever the user wants by adding {status, [{custom, "path/to/hook"}]} to already existing extended_start_script_hooks.
Diffstat (limited to 'src')
-rw-r--r--src/rlx_prv_assembler.erl18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index f40a0c2..278756d 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -398,7 +398,8 @@ write_bin_file(State, Release, OutputDir, RelDir) ->
include_nodetool(BinDir),
Hooks = expand_hooks(BinDir,
rlx_state:get(State,
- extended_start_script_hooks, []),
+ extended_start_script_hooks,
+ [{status, [builtin_status]}]),
State),
extended_bin_file_contents(OsFamily, RelName, RelVsn,
rlx_release:erts(Release), ErlOpts,
@@ -475,6 +476,8 @@ validate_hook(post_start, wait_for_vm_start) -> true;
validate_hook(post_start, {wait_for_process, _}) -> true;
%% custom hooks are allowed in all phases
validate_hook(_Phase, {custom, _}) -> true;
+%% as well as status hooks
+validate_hook(status, _) -> true;
%% deny all others
validate_hook(_, _) -> false.
@@ -482,7 +485,8 @@ hook_filename({custom, CustomScript}) -> CustomScript;
hook_filename(pid) -> "hooks/builtin/pid";
hook_filename({pid, _}) -> "hooks/builtin/pid";
hook_filename(wait_for_vm_start) -> "hooks/builtin/wait_for_vm_start";
-hook_filename({wait_for_process, _}) -> "hooks/builtin/wait_for_process".
+hook_filename({wait_for_process, _}) -> "hooks/builtin/wait_for_process";
+hook_filename(builtin_status) -> "hooks/builtin/status".
hook_invocation({custom, CustomScript}) -> CustomScript;
%% the pid builtin hook with no arguments writes to pid file
@@ -496,13 +500,15 @@ hook_invocation({wait_for_process, Name}) ->
%% wait_for_process takes an atom as argument
%% which is the process name to wait for
string:join(["hooks/builtin/wait_for_process",
- atom_to_list(Name)], "|").
+ atom_to_list(Name)], "|");
+hook_invocation(builtin_status) -> "hooks/builtin/status".
hook_template({custom, _}) -> custom;
hook_template(pid) -> builtin_hook_pid;
hook_template({pid, _}) -> builtin_hook_pid;
hook_template(wait_for_vm_start) -> builtin_hook_wait_for_vm_start;
-hook_template({wait_for_process, _}) -> builtin_hook_wait_for_process.
+hook_template({wait_for_process, _}) -> builtin_hook_wait_for_process;
+hook_template(builtin_status) -> builtin_hook_status.
%% custom hooks are not rendered, they should
%% be copied by the release overlays
@@ -795,6 +801,7 @@ extended_bin_file_contents(OsFamily, RelName, RelVsn, ErtsVsn, ErlOpts, Hooks) -
Hooks, []), " "),
PostInstallUpgradeHooks = string:join(proplists:get_value(post_install_upgrade,
Hooks, []), " "),
+ StatusHook = string:join(proplists:get_value(status, Hooks, []), " "),
render(Template, [{rel_name, RelName}, {rel_vsn, RelVsn},
{erts_vsn, ErtsVsn}, {erl_opts, ErlOpts},
{pre_start_hooks, PreStartHooks},
@@ -802,7 +809,8 @@ extended_bin_file_contents(OsFamily, RelName, RelVsn, ErtsVsn, ErlOpts, Hooks) -
{pre_stop_hooks, PreStopHooks},
{post_stop_hooks, PostStopHooks},
{pre_install_upgrade_hooks, PreInstallUpgradeHooks},
- {post_install_upgrade_hooks, PostInstallUpgradeHooks}]).
+ {post_install_upgrade_hooks, PostInstallUpgradeHooks},
+ {status_hook, StatusHook}]).
erl_ini(OutputDir, ErtsVsn) ->
ErtsDirName = string:concat("erts-", ErtsVsn),