activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject git commit: Fix for APLO-312: Apollo fails to bumb up the ulimit!
Date Fri, 31 Jan 2014 16:09:46 GMT
Updated Branches:
  refs/heads/trunk 2b6867a6c -> db8de8bb9


Fix for APLO-312: Apollo fails to bumb up the ulimit!

- We now do a binary search for the max allowed ulimit bump in case the default is too high.

Project: http://git-wip-us.apache.org/repos/asf/activemq-apollo/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-apollo/commit/db8de8bb
Tree: http://git-wip-us.apache.org/repos/asf/activemq-apollo/tree/db8de8bb
Diff: http://git-wip-us.apache.org/repos/asf/activemq-apollo/diff/db8de8bb

Branch: refs/heads/trunk
Commit: db8de8bb9e1c92d524204d63a4c8c6e834b7dbe3
Parents: 2b6867a
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Fri Jan 31 11:06:40 2014 -0500
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Fri Jan 31 11:06:40 2014 -0500

----------------------------------------------------------------------
 apollo-distro/src/main/release/bin/apollo | 38 ++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/db8de8bb/apollo-distro/src/main/release/bin/apollo
----------------------------------------------------------------------
diff --git a/apollo-distro/src/main/release/bin/apollo b/apollo-distro/src/main/release/bin/apollo
index ea7cc03..cac3ae1 100755
--- a/apollo-distro/src/main/release/bin/apollo
+++ b/apollo-distro/src/main/release/bin/apollo
@@ -157,12 +157,38 @@ if [ ! -z "$APOLLO_BASE" ] ; then
 fi
 
 # Attempt to bump up the ulimit 
-target=100000
-limit=`ulimit -n 2>/dev/null`
-case $limit in
-    unlimited) ;;
-    [0-9]*) [ $limit -lt 10000 ] && ulimit -n $target >/dev/null 2>/dev/null
;;
-    *) ulimit -n $target >/dev/null 2>/dev/null ;;
+if [ -z "$APOLLO_ULIMIT" ] ; then
+  APOLLO_ULIMIT=100000
+fi
+
+# Does a binary search of the max ulimit we can set.
+search_ulimit () {
+  low=$2; mid=$3; hi=$4
+  if [[ $mid -ne $hi && $mid -ne $low ]] ; then
+    ulimit $1 $mid >/dev/null 2>/dev/null
+    if [ $? -eq 0 ] ; then
+      # max ulimit is higher...
+      search_ulimit $1 $mid `expr \( \( $hi - $mid \) / 2 \) + $mid` $hi
+    else
+      # max ulimit is lower...
+      search_ulimit $1 $low `expr \( \( $mid - $low \) / 2 \) + $low` $mid
+    fi
+  fi
+}
+
+set_ulimit () {
+  ulimit $1 $2 >/dev/null 2>/dev/null
+  if [ $? -ne 0 ] ; then
+    search_ulimit $1 0 `expr  $2 / 2` $2
+  fi
+}
+
+case $APOLLO_ULIMIT in
+  [0-9]*)  
+    set_ulimit -n $APOLLO_ULIMIT # sets the file descriptor limit
+    set_ulimit -u $APOLLO_ULIMIT # sets the process limit to help us run lots of threads.
+  ;;
+  *) ;;
 esac
 
 ${EXEC} "$JAVACMD" ${JVM_FLAGS} ${SYSTEM_PROPS} -classpath "${CLASSPATH}" org.apache.activemq.apollo.boot.Apollo
${BOOTDIRS} org.apache.activemq.apollo.cli.Apollo $@


Mime
View raw message