aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--priv/templates/extended_bin.dtl58
1 files changed, 30 insertions, 28 deletions
diff --git a/priv/templates/extended_bin.dtl b/priv/templates/extended_bin.dtl
index 751b01f..70b4ee2 100644
--- a/priv/templates/extended_bin.dtl
+++ b/priv/templates/extended_bin.dtl
@@ -26,6 +26,18 @@ find_erts_dir() {
fi
}
+# Get node pid
+relx_get_pid() {
+ if output="$(relx_nodetool rpcterms os getpid)"
+ then
+ echo "$output" | sed -e 's/"//g'
+ return 0
+ else
+ echo "$output"
+ return 1
+ fi
+}
+
# Connect to a remote node
relx_rem_sh() {
# Generate a unique id used to allow multiple remsh to the same node
@@ -61,6 +73,7 @@ relx_escript() {
"$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" $@
}
+
# Output a start command for the last argument of run_erl
relx_start_command() {
printf "exec \"%s\" \"%s\"" "$RELEASE_ROOT_DIR/bin/$REL_NAME" \
@@ -194,24 +207,9 @@ case "$1" in
stop)
# Wait for the node to completely stop...
- case $(uname -s) in
- Linux|Darwin|FreeBSD|DragonFly|NetBSD|OpenBSD)
- # PID COMMAND
- PID=$(ps ax -o pid= -o command=|
- grep "$RELEASE_ROOT_DIR/.*/[b]eam"|awk '{print $1}')
- ;;
- SunOS)
- # PID COMMAND
- PID=$(ps -ef -o pid= -o args=|
- grep "$RELEASE_ROOT_DIR/.*/[b]eam"|awk '{print $1}')
- ;;
- CYGWIN*)
- # UID PID PPID TTY STIME COMMAND
- PID=$(ps -efw|grep "$RELEASE_ROOT_DIR/.*/[b]eam"|awk '{print $2}')
- ;;
- esac
+ PID="$(relx_get_pid)"
if ! relx_nodetool "stop"; then
- exit $?
+ exit 1
fi
while $(kill -0 "$PID" 2>/dev/null);
do
@@ -222,37 +220,43 @@ case "$1" in
restart)
## Restart the VM without exiting the process
if ! relx_nodetool "restart"; then
- exit $?
+ exit 1
fi
;;
reboot)
## Restart the VM completely (uses heart to restart it)
if ! relx_nodetool "reboot"; then
- exit $?
+ exit 1
+ fi
+ ;;
+
+ pid)
+ ## Get the VM's pid
+ if ! relx_get_pid; then
+ exit 1
fi
;;
ping)
## See if the VM is alive
if ! relx_nodetool "ping"; then
- exit $?
+ exit 1
fi
;;
escript)
## Run an escript under the node's environment
if ! relx_escript $@; then
- exit $?
+ exit 1
fi
;;
attach)
# Make sure a node IS running
if ! relx_nodetool "ping" > /dev/null; then
- ES="$?"
echo "Node is not running!"
- exit $ES
+ exit 1
fi
shift
@@ -262,9 +266,8 @@ case "$1" in
remote_console)
# Make sure a node IS running
if ! relx_nodetool "ping" > /dev/null; then
- ES="$?"
echo "Node is not running!"
- exit $ES
+ exit 1
fi
shift
@@ -281,9 +284,8 @@ case "$1" in
# Make sure a node IS running
if ! relx_nodetool "ping" > /dev/null; then
- ES="$?"
echo "Node is not running!"
- exit $ES
+ exit 1
fi
exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
@@ -372,7 +374,7 @@ case "$1" in
exec "$@" -- ${1+$ARGS}
;;
*)
- echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|console_clean|console_boot <file>|attach|remote_console|upgrade|escript}"
+ echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|pid|ping|console|console_clean|console_boot <file>|attach|remote_console|upgrade|escript}"
exit 1
;;
esac