aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2022-04-25 10:53:14 +0200
committerBadlop <badlop@process-one.net>2022-05-02 13:25:18 +0200
commitb0db87c683d797c553eda5900f25882fd6678b5e (patch)
tree6348690531061a72122546f2debe0f1b525cbffa /.github
parentContainer: Start BEAM with exec to maintain the PID and catch SIGTERM in Dock... (diff)
Container: Experimental support CTL_ON_CREATE and CTL_ON_START environment variables
Diffstat (limited to '.github')
-rwxr-xr-x.github/container/ejabberdctl.template27
1 files changed, 27 insertions, 0 deletions
diff --git a/.github/container/ejabberdctl.template b/.github/container/ejabberdctl.template
index fe2404d48..c25ac9ef4 100755
--- a/.github/container/ejabberdctl.template
+++ b/.github/container/ejabberdctl.template
@@ -252,6 +252,28 @@ check_start()
}
}
+post_waiter_fork()
+{
+ (FIRST_RUN=$FIRST_RUN "$0" post_waiter)&
+}
+
+post_waiter_waiting()
+{
+ $0 started
+ [ -n "$FIRST_RUN" ] && [ -n "$CTL_ON_CREATE" ] && (post_waiter_loop $CTL_ON_CREATE)
+ [ -n "$CTL_ON_START" ] && post_waiter_loop $CTL_ON_START
+}
+
+post_waiter_loop()
+{
+ LIST=$@
+ HEAD=${LIST%% ; *}
+ TAIL=${LIST#* ; }
+ echo ":> ejabberdctl $HEAD"
+ $0 $HEAD
+ [ "$HEAD" = "$TAIL" ] || post_waiter_loop $TAIL
+}
+
# allow sync calls
wait_status()
{
@@ -274,6 +296,7 @@ wait_status()
}
# ensure we can change current directory to SPOOL_DIR
+[ -f "$SPOOL_DIR/schema.DAT" ] || FIRST_RUN=true
[ -d "$SPOOL_DIR" ] || run_cmd mkdir -p "$SPOOL_DIR"
cd "$SPOOL_DIR" || {
echo "ERROR: can not access directory $SPOOL_DIR"
@@ -288,6 +311,7 @@ case $1 in
;;
foreground)
check_start
+ post_waiter_fork
exec_erl "$ERLANG_NODE" $EJABBERD_OPTS -noinput
;;
foreground-quiet)
@@ -328,6 +352,9 @@ case $1 in
stopped)
wait_status 3 30 2 && stop_epmd # wait 30x2s before timeout
;;
+ post_waiter)
+ post_waiter_waiting
+ ;;
*)
run_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT "$@"