How to stop a detached OTP app?
Armando Di Cianno
armando@REDACTED
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
USER="myuser"
APP="myapp"
HOSTNAME=`hostname -f`
NODE="${APP}@${HOSTNAME}"
RELEASE_PATH="/usr/local/lib/${APP}"
HOME="/var/lib/${APP}"
LOG_PATH="/var/log/${APP}"
case "$1" in
"start")
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"
;;
"stop")
su ${USER} -p -c \
"erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE}
-eval \"init:stop()\" -noshell"
;;
"debug")
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
;;
esac
exit 0
### end
For stopping, I've tried:
* erl -pa ${RELEASE_PATH}/ebin -name ctl_${NODE} -remsh ${NODE} -eval
"init:stop()"
* 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,
__armando
More information about the erlang-questions
mailing list