Created
May 22, 2014 16:24
-
-
Save tsloughter/a65de7f1a6863eccd3bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
SCRIPT_DIR="$(dirname "$0")" | |
RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" | |
REL_NAME="recon_demo" | |
REL_VSN="1.0.0" | |
ERTS_VSN="6.0" | |
REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN" | |
ERL_OPTS="" | |
find_erts_dir() { | |
local erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN" | |
if [ -d "$erts_dir" ]; then | |
ERTS_DIR="$erts_dir"; | |
ROOTDIR="$RELEASE_ROOT_DIR" | |
else | |
local erl="$(which erl)" | |
local erl_root=$("$erl" -noshell -eval "io:format(\"~s\", [code:root_dir()])." -s init stop) | |
ERTS_DIR="$erl_root/erts-$ERTS_VSN" | |
fi | |
} | |
find_sys_config() { | |
local possible_sys="$REL_DIR/sys.config" | |
if [ -f "$possible_sys" ]; then | |
SYS_CONFIG="$possible_sys" | |
fi | |
} | |
find_vm_args() { | |
local possible_vm_args="$REL_DIR/vm.args" | |
if [ -f "$possible_vm_args" ]; then | |
VM_ARGS="$possible_vm_args" | |
fi | |
} | |
find_erts_dir | |
find_sys_config | |
find_vm_args | |
export ROOTDIR="$RELEASE_ROOT_DIR" | |
export BINDIR="$ERTS_DIR/bin" | |
export EMU="beam" | |
export PROGNAME="erl" | |
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH" | |
cd "$ROOTDIR" | |
# Save extra arguments | |
ARGS="$@" | |
# Build arguments for erlexec | |
set -- "$ERL_OPTS" | |
[ "$SYS_CONFIG" ] && set -- "$@" -config "$SYS_CONFIG" | |
[ "$VM_ARGS" ] && set -- "$@" -args_file "$VM_ARGS" | |
set -- "$@" -boot "$REL_DIR/$REL_NAME" "$ARGS" | |
# Boot the release | |
$BINDIR/erlexec $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment