summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2010-02-12 20:25:31 +0100
committerBadlop <badlop@process-one.net>2010-02-12 20:25:31 +0100
commit7c36e304f059575b109cb4b29767227fa21537ed (patch)
treeb84052e446097dabd7f0c48a3c1c623d99a9a8fd
parentejabberdctl: support concurrent connections with bound conn names (diff)
Minor fixes in the new ejabberdctl flock code
-rw-r--r--src/Makefile.in5
-rw-r--r--src/ejabberdctl.template45
2 files changed, 24 insertions, 26 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 02f05e89..eb999d91 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -233,13 +233,12 @@ install: all
install -d -m 750 $(O_USER) $(SPOOLDIR)
$(CHOWN_COMMAND) -R @INSTALLUSER@ $(SPOOLDIR) >$(CHOWN_OUTPUT)
chmod -R 750 $(SPOOLDIR)
-
+ [ ! -f $(COOKIEFILE) ] || { $(CHOWN_COMMAND) @INSTALLUSER@ $(COOKIEFILE) >$(CHOWN_OUTPUT) ; chmod 400 $(COOKIEFILE) ; }
+ #
# ejabberdctl lock directory
install -d -m 750 $(O_USER) $(CTLLOCKDIR)
$(CHOWN_COMMAND) -R @INSTALLUSER@ $(CTLLOCKDIR) >$(CHOWN_OUTPUT)
chmod -R 750 $(CTLLOCKDIR)
-
- [ ! -f $(COOKIEFILE) ] || { $(CHOWN_COMMAND) @INSTALLUSER@ $(COOKIEFILE) >$(CHOWN_OUTPUT) ; chmod 400 $(COOKIEFILE) ; }
#
# Log directory
install -d -m 750 $(O_USER) $(LOGDIR)
diff --git a/src/ejabberdctl.template b/src/ejabberdctl.template
index f5af13be..b2692289 100644
--- a/src/ejabberdctl.template
+++ b/src/ejabberdctl.template
@@ -14,17 +14,6 @@ ERLANG_NODE=$NODE@$HOST
ERL=@erl@
INSTALLUSER=@installuser@
-# Control number of connections identifiers
-# using flock if available. Expects a linux-style
-# flock that can lock a file descriptor.
-MAXCONNID=100
-CONNLOCKDIR=@LOCALSTATEDIR@/lock/ejabberdctl
-FLOCK='/usr/bin/flock'
-if [ ! -x "$FLOCK" ];then
- FLOCK=""
-fi
-
-
# parse command line parameters
ARGS=
while [ $# -ne 0 ] ; do
@@ -164,7 +153,7 @@ debug ()
echo ""
echo "IMPORTANT: we will attempt to attach an INTERACTIVE shell"
echo "to an already running ejabberd node."
- echo "If an ERROR is printed, it means the connection was not succesfull."
+ echo "If an ERROR is printed, it means the connection was not successful."
echo "You can interact with the ejabberd node if you know how to use it."
echo "Please be extremely cautious with your actions,"
echo "and exit immediately if you are not completely sure."
@@ -240,16 +229,26 @@ ctl ()
{
COMMAND=$@
- if [ ! "$FLOCK" ];then
+ # Control number of connections identifiers
+ # using flock if available. Expects a linux-style
+ # flock that can lock a file descriptor.
+ MAXCONNID=100
+ CONNLOCKDIR=@LOCALSTATEDIR@/lock/ejabberdctl
+ FLOCK='/usr/bin/flock'
+ if [ ! -x "$FLOCK" ] ; then
+ FLOCK=""
+ fi
+
+ if [ ! "$FLOCK" ] ; then
# no flock, simply invoke ctlexec()
- CTL_CONN="ctl-${EJABBERD_NODE}"
+ CTL_CONN="ctl-${ERLANG_NODE}"
ctlexec $CTL_CONN $COMMAND
result=$?
else
# we have flock so we get a lock
# on one of a limited number of
# conn names -- this allows
- # concurrent invokations using a bound
+ # concurrent invocations using a bound
# number of atoms
for N in $(seq 1 $MAXCONNID); do
CTL_CONN="ejabberdctl-$N"
@@ -281,17 +280,17 @@ ctl ()
fi
if [ "$badlock" ];then
- 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 "busy servers, consider raising MAXCONNIDS" >&2
- exit 1;
+ 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 "busy servers, consider raising MAXCONNID in ejabberdctl">&2
+ exit 1;
fi
case $result in
- 0) :;;
- 1) :;;
- 2) help;;
- 3) help;;
+ 0) :;;
+ 1) :;;
+ 2) help;;
+ 3) help;;
esac
return $result
}