How to stop a detached OTP app?

Armando Di Cianno <>
Fri Aug 20 21:39:43 CEST 2010

I'm most certainly doing something braindead, which is stopping me
from being able to nicely stop an OTP app I've written.

I've written a script to help me start, stop, and connect to the app
for debugging purposes. However, no variation of 'stop' I've tried
seems to work.

Here's the script:
### start
#!/usr/bin/env bash

HOSTNAME=`hostname -f`

case "$1" in
		su ${USER} -p -c \
			"erl -pa ${RELEASE_PATH}/ebin -name ${NODE} -boot ${APP} -mnesia
dir '\"${HOME}\"' -sasl sasl_error_logger '{file,
\"${LOG_PATH}/erlang.log\"}' -detached"
		su ${USER} -p -c \
			"erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE}
-eval \"init:stop()\" -noshell"
		echo "*** Use Ctrl-C Ctrl-C to exit. ***"
		su ${USER} -p -c \
			"erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE}"
		echo "Please use 'start', 'stop', or 'debug."
		exit 1

exit 0
### end

For stopping, I've tried:
* erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE} -eval
* erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE} -s init stop
* erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE} -s
${APP} -extra stop  #where I've added some command arg processing to
the app
... and some other variantions.

If I connect to the app using the debug mode of my script, and issue
init:stop(), everything shuts down nicely.

Thanks for any insights into this. Cheers,

More information about the erlang-questions mailing list