Skip to content

Commit 76ab164

Browse files
committed
Support ERL_DIST_PORT
1 parent 890d04c commit 76ab164

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ecs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ ADD --chown=ejabberd:ejabberd https://download.process-one.net/cacert.pem conf/c
115115
# Setup runtime environment
116116
USER ejabberd
117117
VOLUME ["$HOME/database","$HOME/conf","$HOME/logs","$HOME/upload"]
118-
EXPOSE 1880 1883 4369-4399 5222 5269 5280 5443
118+
EXPOSE 1880 1883 4369-4399 5210 5222 5269 5280 5443
119119

120120
ENTRYPOINT ["/sbin/tini","--","/home/ejabberd/bin/ejabberdctl"]
121121
CMD ["foreground"]

ecs/bin/ejabberdctl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ if [ -n "$INET_DIST_INTERFACE" ] ; then
8787
ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_use_interface $INET_DIST_INTERFACE2"
8888
fi
8989
fi
90+
[ -n "$ERL_DIST_PORT" ] && ERLANG_OPTS="$ERLANG_OPTS -erl_epmd_port $ERL_DIST_PORT -start_epmd false"
9091
ERL_LIBS="$ROOT_DIR/lib"
9192
# if vm.args file exists in config directory, pass it to Erlang VM
9293
[ -f "$VMARGS" ] && ERLANG_OPTS="$ERLANG_OPTS -args_file $VMARGS"
@@ -109,13 +110,19 @@ export EJABBERD_LOG_PATH
109110
export EJABBERD_PID_PATH
110111
export ERL_CRASH_DUMP
111112
export ERL_EPMD_ADDRESS
113+
export ERL_DIST_PORT
112114
export ERL_INETRC
113115
export ERL_MAX_PORTS
114116
export ERL_MAX_ETS_TABLES
115117
export CONTRIB_MODULES_PATH
116118
export CONTRIB_MODULES_CONF_DIR
117119
export ERL_LIBS
118120

121+
set_dist_client()
122+
{
123+
[ -n "$ERL_DIST_PORT" ] && ERLANG_OPTS="$ERLANG_OPTS -dist_listen false"
124+
}
125+
119126
# run command either directly or via su $INSTALLUSER
120127
run_cmd()
121128
{
@@ -272,6 +279,7 @@ uid()
272279
# stop epmd if there is no other running node
273280
stop_epmd()
274281
{
282+
[ -n "$ERL_DIST_PORT" ] && return
275283
"$EPMD" -names 2>/dev/null | grep -q name || "$EPMD" -kill >/dev/null
276284
}
277285

@@ -280,6 +288,7 @@ stop_epmd()
280288
# then (docker case) make .sql files available on database volume
281289
check_start()
282290
{
291+
[ -n "$ERL_DIST_PORT" ] && return
283292
"$EPMD" -names 2>/dev/null | grep -q " ${ERLANG_NODE%@*} " && {
284293
pgrep -f "$ERLANG_NODE" >/dev/null && {
285294
echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running."
@@ -380,16 +389,19 @@ case $1 in
380389
;;
381390
debug)
382391
debugwarning
392+
set_dist_client
383393
exec_erl "$(uid debug)" -hidden -remsh "$ERLANG_NODE" \
384394
-boot start_clean
385395
;;
386396
etop)
397+
set_dist_client
387398
exec_erl "$(uid top)" -hidden -node "$ERLANG_NODE" -s etop \
388399
-s erlang halt -output text \
389400
-boot start_clean
390401
;;
391402
iexdebug)
392403
debugwarning
404+
set_dist_client
393405
exec_iex "$(uid debug)" --remsh "$ERLANG_NODE" --boot start_clean
394406
;;
395407
iexlive)
@@ -399,21 +411,25 @@ case $1 in
399411
ping)
400412
PEER=${2:-$ERLANG_NODE}
401413
[ "$PEER" = "${PEER%.*}" ] && PS="-s"
414+
set_dist_client
402415
exec_cmd "$ERL" ${PS:--}name "$(uid ping "$(hostname $PS)")" $ERLANG_OPTS \
403416
-noinput -hidden -eval 'io:format("~p~n",[net_adm:ping('"'$PEER'"')])' \
404417
-s erlang halt -output text \
405418
-boot start_clean
406419
;;
407420
started)
421+
set_dist_client
408422
wait_status 0 30 2 # wait 30x2s before timeout
409423
;;
410424
stopped)
425+
set_dist_client
411426
wait_status 3 30 2 && stop_epmd # wait 30x2s before timeout
412427
;;
413428
post_waiter)
414429
post_waiter_waiting
415430
;;
416431
*)
432+
set_dist_client
417433
run_erl "$(uid ctl)" -hidden -noinput -boot start_clean \
418434
-s ejabberd_ctl -extra "$ERLANG_NODE" $NO_TIMEOUT "$@"
419435
result=$?

0 commit comments

Comments
 (0)