aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2022-04-25 10:52:38 +0200
committerBadlop <badlop@process-one.net>2022-05-02 13:25:18 +0200
commit200cea25c80c57fce9a5b4138cec45f60020a7c2 (patch)
tree915f9dc93545f33a730b22e6bc2104e5e75178e9 /.github
parentContainer: Copy ejabberdctl.template, it requires some customizations (diff)
Container: Start BEAM with exec to maintain the PID and catch SIGTERM in Docker Stop
Until now, when stopping the ejabberd container, Erlang is not gracefully closed, Mnesia is not properly closed... exit code is 137. With this change, when the container is stopped, Erlang receives the SIGTERM signal, shutsdown, Mnesia database is properly closed, ... and exit code is 0.
Diffstat (limited to '.github')
-rwxr-xr-x.github/container/ejabberdctl.template20
1 files changed, 16 insertions, 4 deletions
diff --git a/.github/container/ejabberdctl.template b/.github/container/ejabberdctl.template
index 5b9ef36cb..fe2404d48 100755
--- a/.github/container/ejabberdctl.template
+++ b/.github/container/ejabberdctl.template
@@ -109,13 +109,25 @@ export ERL_LIBS
export SCRIPT_DIR
# run command either directly or via su $INSTALLUSER
-exec_cmd()
+run_cmd()
{
case $EXEC_CMD in
as_install_user) su -s /bin/sh -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;;
as_current_user) "$@" ;;
esac
}
+exec_cmd()
+{
+ case $EXEC_CMD in
+ as_install_user) su -s /bin/sh -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;;
+ as_current_user) exec "$@" ;;
+ esac
+}
+run_erl()
+{
+ NODE=$1; shift
+ run_cmd "$ERL" ${S:--}name "$NODE" $ERLANG_OPTS "$@"
+}
exec_erl()
{
NODE=$1; shift
@@ -253,7 +265,7 @@ wait_status()
if [ $timeout -eq 0 ] ; then
status="$1"
else
- exec_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
+ run_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT status > /dev/null
status="$?"
fi
@@ -262,7 +274,7 @@ wait_status()
}
# ensure we can change current directory to SPOOL_DIR
-[ -d "$SPOOL_DIR" ] || exec_cmd mkdir -p "$SPOOL_DIR"
+[ -d "$SPOOL_DIR" ] || run_cmd mkdir -p "$SPOOL_DIR"
cd "$SPOOL_DIR" || {
echo "ERROR: can not access directory $SPOOL_DIR"
exit 6
@@ -317,7 +329,7 @@ case $1 in
wait_status 3 30 2 && stop_epmd # wait 30x2s before timeout
;;
*)
- exec_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
+ run_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT "$@"
result=$?
case $result in