Skip to content

Commit

Permalink
Refactor foreground command
Browse files Browse the repository at this point in the history
Move it next to console since it's mostly the
same thing but with extra parameters.
  • Loading branch information
lrascao committed Nov 5, 2016
1 parent f74972a commit 3b9239d
Showing 1 changed file with 14 additions and 34 deletions.
48 changes: 14 additions & 34 deletions priv/templates/extended_bin
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ case "$1" in
"versions" "{'$REL_NAME', \"$NAME_TYPE\", '$NAME', '$COOKIE'}" "$@"
;;

console|console_clean|console_boot)
console|console_clean|console_boot|foreground)
__code_paths=""
FOREGROUNDOPTIONS=""
# .boot file typically just $REL_NAME (ie, the app name)
# however, for debugging, sometimes start_clean.boot is useful.
# For e.g. 'setup', one may even want to name another boot script.
Expand All @@ -417,6 +418,16 @@ case "$1" in
BOOTFILE="$REL_DIR/start"
fi
;;
foreground)
# start up the release in the foreground for use by runit
# or other supervision services
if [ -f "$REL_DIR/$REL_NAME.boot" ]; then
BOOTFILE="$REL_DIR/$REL_NAME"
else
BOOTFILE="$REL_DIR/start"
fi
FOREGROUNDOPTIONS="-noshell -noinput +Bd"
;;
console_clean)
__code_paths=$(relx_get_code_paths)
BOOTFILE="$ROOTDIR/bin/start_clean"
Expand All @@ -439,7 +450,8 @@ case "$1" in

# 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" -mode "$CODE_LOADING_MODE" \
set -- "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
-boot "$BOOTFILE" -mode "$CODE_LOADING_MODE" \
-boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
-config "$RELX_CONFIG_PATH" \
-args_file "$VMARGS_PATH" \
Expand All @@ -453,38 +465,6 @@ case "$1" in
echo "$RELEASE_ROOT_DIR"
logger -t "$REL_NAME[$$]" "Starting up"

# Start the VM
exec "$@" -- ${1+$ARGS}
;;

foreground)
# start up the release in the foreground for use by runit
# or other supervision services

[ -f "$REL_DIR/$REL_NAME.boot" ] && BOOTFILE="$REL_NAME" || BOOTFILE=start
FOREGROUNDOPTIONS="-noshell -noinput +Bd"

# Setup beam-required vars
EMU=beam
PROGNAME="${0#*/}"

export EMU
export PROGNAME

# Store passed arguments since they will be erased by `set`
ARGS="$@"

# 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" $FOREGROUNDOPTIONS \
-boot "$REL_DIR/$BOOTFILE" -mode "$CODE_LOADING_MODE" -config "$RELX_CONFIG_PATH" \
-boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
-args_file "$VMARGS_PATH"

# Dump environment info for logging purposes
echo "Exec: $@" -- ${1+$ARGS}
echo "Root: $ROOTDIR"

# Start the VM
exec "$@" -- ${1+$ARGS}
;;
Expand Down

0 comments on commit 3b9239d

Please sign in to comment.