From 82f6c94a4d8ef1cf2be0becc5816d0646e5a50cc Mon Sep 17 00:00:00 2001 From: Luis Rascao Date: Sun, 14 May 2017 02:15:05 +0100 Subject: 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. --- priv/templates/builtin_hook_status | 3 +++ priv/templates/extended_bin | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 priv/templates/builtin_hook_status (limited to 'priv') diff --git a/priv/templates/builtin_hook_status b/priv/templates/builtin_hook_status new file mode 100644 index 0000000..e5dd792 --- /dev/null +++ b/priv/templates/builtin_hook_status @@ -0,0 +1,3 @@ +#!/bin/bash + +echo $(relx_nodetool eval "application:which_applications().") diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin index 3090368..ed68748 100755 --- a/priv/templates/extended_bin +++ b/priv/templates/extended_bin @@ -102,8 +102,12 @@ relx_usage() { echo " --no-permanent Install release package VERSION but" echo " don't make it permanent" ;; + status) + echo "Usage: $REL_NAME status" + echo "Obtains node status information." + ;; *) - echo "Usage: $REL_NAME {start|start_boot |foreground|stop|restart|reboot|pid|ping|console|console_clean|console_boot |attach|remote_console|upgrade|downgrade|install|uninstall|versions|escript|rpc|rpcterms|eval}" + echo "Usage: $REL_NAME {start|start_boot |foreground|stop|restart|reboot|pid|ping|console|console_clean|console_boot |attach|remote_console|upgrade|downgrade|install|uninstall|versions|escript|rpc|rpcterms|eval|status}" ;; esac } @@ -585,6 +589,15 @@ case "$1" in shift relx_nodetool "eval" $@ ;; + status) + # Make sure a node IS running + if ! relx_nodetool "ping" > /dev/null; then + echo "Node is not running!" + exit 1 + fi + + [ "$SCRIPT_DIR/$STATUS_HOOK" ] && . "$SCRIPT_DIR/$STATUS_HOOK" $@ + ;; help) if [ -z "$2" ]; then relx_usage -- cgit v1.2.3