mirror of
https://github.com/processone/ejabberd.git
synced 2024-07-04 23:15:31 +02:00
Check node name is available before starting ejabberd (EJAB-1572)
This commit is contained in:
parent
9787416e88
commit
9442a583bc
|
@ -41,7 +41,9 @@ fi
|
||||||
if [ "$EJABBERDCTL_CONFIG_PATH" = "" ] ; then
|
if [ "$EJABBERDCTL_CONFIG_PATH" = "" ] ; then
|
||||||
EJABBERDCTL_CONFIG_PATH=$ETCDIR/ejabberdctl.cfg
|
EJABBERDCTL_CONFIG_PATH=$ETCDIR/ejabberdctl.cfg
|
||||||
fi
|
fi
|
||||||
[ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
|
if [ -f "$EJABBERDCTL_CONFIG_PATH" ] ; then
|
||||||
|
. "$EJABBERDCTL_CONFIG_PATH"
|
||||||
|
fi
|
||||||
if [ "$LOGS_DIR" = "" ] ; then
|
if [ "$LOGS_DIR" = "" ] ; then
|
||||||
LOGS_DIR=@LOCALSTATEDIR@/log/ejabberd
|
LOGS_DIR=@LOCALSTATEDIR@/log/ejabberd
|
||||||
fi
|
fi
|
||||||
|
@ -75,7 +77,9 @@ if [ "$EXEC_CMD" = "false" ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NAME=-name
|
NAME=-name
|
||||||
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && NAME=-sname
|
if [ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] ; then
|
||||||
|
NAME=-sname
|
||||||
|
fi
|
||||||
|
|
||||||
KERNEL_OPTS=""
|
KERNEL_OPTS=""
|
||||||
if [ "$FIREWALL_WINDOW" != "" ] ; then
|
if [ "$FIREWALL_WINDOW" != "" ] ; then
|
||||||
|
@ -88,22 +92,22 @@ fi
|
||||||
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS"
|
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS"
|
||||||
|
|
||||||
# define additional environment variables
|
# define additional environment variables
|
||||||
if [ "$EJABBERDDIR" = "" ]; then
|
if [ "$EJABBERDDIR" = "" ] ; then
|
||||||
EJABBERDDIR=@LIBDIR@/ejabberd
|
EJABBERDDIR=@LIBDIR@/ejabberd
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_EBIN_PATH" = "" ]; then
|
if [ "$EJABBERD_EBIN_PATH" = "" ] ; then
|
||||||
EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
|
EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_PRIV_PATH" = "" ]; then
|
if [ "$EJABBERD_PRIV_PATH" = "" ] ; then
|
||||||
EJABBERD_PRIV_PATH=$EJABBERDDIR/priv
|
EJABBERD_PRIV_PATH=$EJABBERDDIR/priv
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_BIN_PATH" = "" ]; then
|
if [ "$EJABBERD_BIN_PATH" = "" ] ; then
|
||||||
EJABBERD_BIN_PATH=$EJABBERD_PRIV_PATH/bin
|
EJABBERD_BIN_PATH=$EJABBERD_PRIV_PATH/bin
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_SO_PATH" = "" ]; then
|
if [ "$EJABBERD_SO_PATH" = "" ] ; then
|
||||||
EJABBERD_SO_PATH=$EJABBERD_PRIV_PATH/lib
|
EJABBERD_SO_PATH=$EJABBERD_PRIV_PATH/lib
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_MSGS_PATH" = "" ]; then
|
if [ "$EJABBERD_MSGS_PATH" = "" ] ; then
|
||||||
EJABBERD_MSGS_PATH=$EJABBERD_PRIV_PATH/msgs
|
EJABBERD_MSGS_PATH=$EJABBERD_PRIV_PATH/msgs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -292,7 +296,7 @@ ctl ()
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
result=$?
|
result=$?
|
||||||
if [ $result -eq 1 ]; then
|
if [ $result -eq 1 ] ; then
|
||||||
# means we errored out in flock
|
# means we errored out in flock
|
||||||
# rather than in the exec - stay in the loop
|
# rather than in the exec - stay in the loop
|
||||||
# trying other conn names...
|
# trying other conn names...
|
||||||
|
@ -305,7 +309,7 @@ ctl ()
|
||||||
result=$(expr $result / 10)
|
result=$(expr $result / 10)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$badlock" ];then
|
if [ "$badlock" ] ;then
|
||||||
echo "Ran out of connections to try. Your ejabberd processes" >&2
|
echo "Ran out of connections to try. Your ejabberd processes" >&2
|
||||||
echo "may be stuck or this is a very busy server. For very" >&2
|
echo "may be stuck or this is a very busy server. For very" >&2
|
||||||
echo "busy servers, consider raising MAXCONNID in ejabberdctl">&2
|
echo "busy servers, consider raising MAXCONNID in ejabberdctl">&2
|
||||||
|
@ -352,13 +356,13 @@ check_start()
|
||||||
{
|
{
|
||||||
epmd -names | grep -q $NODE && {
|
epmd -names | grep -q $NODE && {
|
||||||
ps ux | grep -v grep | grep -q $ERLANG_NODE && {
|
ps ux | grep -v grep | grep -q $ERLANG_NODE && {
|
||||||
echo "ejabberd is already running."
|
echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running."
|
||||||
exit 4
|
exit 4
|
||||||
} || {
|
} || {
|
||||||
ps ux | grep beam | grep -v "grep beam" && {
|
ps ux | grep beam | grep -v "grep beam" && {
|
||||||
echo "ejabberd node is registered, but no ejabberd process has been found."
|
echo "ERROR: The ejabberd node '$ERLANG_NODE' is registered,"
|
||||||
echo "can not kill epmd as other erlang nodes are running."
|
echo " but no ejabberd process has been found."
|
||||||
echo "please stop all erlang nodes, and call 'epmd -kill'."
|
echo "Shutdown other erlang nodes, and call 'epmd -kill'."
|
||||||
exit 5
|
exit 5
|
||||||
} || {
|
} || {
|
||||||
epmd -kill
|
epmd -kill
|
||||||
|
@ -374,7 +378,7 @@ wait_for_status()
|
||||||
# return: 0 OK, 1 KO
|
# return: 0 OK, 1 KO
|
||||||
timeout=$2
|
timeout=$2
|
||||||
status=4
|
status=4
|
||||||
while [ $status -ne $1 ]; do
|
while [ $status -ne $1 ] ; do
|
||||||
sleep $3
|
sleep $3
|
||||||
timeout=$(($timeout - 1))
|
timeout=$(($timeout - 1))
|
||||||
[ $timeout -eq 0 ] && {
|
[ $timeout -eq 0 ] && {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user