erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
697 stars 232 forks source link

Extended start script hooks for the other commands #758

Open seanhinde opened 4 years ago

seanhinde commented 4 years ago

There are currently extended hooks for start / stop and status. I use these to set VMARGS_PATH to start my node with specific config for this server using a release based on multiple profiles (especially the cookie).

Trouble is that ping, remote_console, attach and other nodetool based extended start script commands don't have hooks and there appears to be no way to hook into their environment. They just look in the default place for vm.args and hence in my case pick up different config to that used during startup.

One trivial workaround is just to call

relx_run_hooks "$PRE_START_HOOKS"

at a suitable place in the main script so all the sub commands can benefit from the updated environment provided by the hook.

I put it just here:

# Extract the name type and name from the NAME_ARG for REMSH
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"

relx_run_hooks "$PRE_START_HOOKS"   # <<<<<<<<<<<<<<

# Extract dist arguments
MAYBE_DIST_ARGS=""
PROTO_DIST="$(grep '^-proto_dist' "$VMARGS_PATH" || true)"
if [ "$PROTO_DIST" ]; then
    MAYBE_DIST_ARGS="${PROTO_DIST}"
fi

Any idea of a standard way to achieve this?

tsloughter commented 4 years ago

I think a pre start hook that runs for all commands makes sense to add.