aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberdctl.template
diff options
context:
space:
mode:
Diffstat (limited to 'src/ejabberdctl.template')
-rw-r--r--src/ejabberdctl.template33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ejabberdctl.template b/src/ejabberdctl.template
index eb85ce266..f6a30bb09 100644
--- a/src/ejabberdctl.template
+++ b/src/ejabberdctl.template
@@ -239,9 +239,42 @@ usage ()
exit
}
+# stop epmd if there is no other running node
+stop_epmd()
+{
+ epmd -names | grep -q name || epmd -kill
+}
+
+# allow sync calls
+wait_for_status()
+{
+ # args: status try delay
+ # return: 0 OK, 1 KO
+ timeout=$2
+ status=4
+ while [ $status -ne $1 ]; do
+ sleep $3
+ let timeout=timeout-1
+ [ $timeout -eq 0 ] && {
+ status=$1
+ } || {
+ ctl status > /dev/null
+ status=$?
+ }
+ done
+ [ $timeout -eq 0 ] && {
+ status=1
+ } || {
+ status=0
+ }
+ return $status
+}
+
case $ARGS in
' start') start;;
' debug') debug;;
' live') live;;
+ ' started') wait_for_status 0 30 2;; # wait 30x2s before timeout
+ ' stopped') wait_for_status 3 15 2; stop_epmd;; # wait 15x2s before timeout
*) ctl $ARGS;;
esac