Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Check limits, start epmd and create datadir only on start.

Resolves MB-4081.

Change-Id: Ibb535e80ab1eb984b8625475abb191aed74d350d
Reviewed-on: http://review.couchbase.org/8113
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
commit 8d32b325cf33d9e0eb64cbbaf88f2590b4e29680 1 parent 1807884
@aartamonau aartamonau authored alk committed
Showing with 35 additions and 26 deletions.
  1. +35 −26 membase-server.sh.in
View
61 membase-server.sh.in
@@ -18,32 +18,6 @@
PATH="@PREFIX@/bin":$PATH
export PATH
-if [ `ulimit -n` -lt 10240 ]
-then
- cat <<EOF
-The maximum number of open files for the membase user is set too low.
-It must be at least 10240. Normally this can be increased by adding
-the following lines to /etc/security/limits.conf:
-
-couchbase soft nofile <value>
-couchbase hard nofile <value>
-
-Where <value> is greater than 10240.
-EOF
-fi
-
-datadir="@PREFIX@/var/lib/membase"
-
-test -d "$datadir" || mkdir -p "$datadir"
-cd "$datadir"
-
-# Initialize distributed erlang on the system (i.e. epmd)
-erl -noshell -setcookie nocookie -sname init -run init stop 2>&1 > /dev/null
-if [ $? -ne 0 ]
-then
- exit 1
-fi
-
ERL_LIBS="@PREFIX@/lib/couchdb/erlang/lib:@PREFIX@/lib/ns_server/erlang/lib:@PREFIX@/lib/couchdb/plugins"
export ERL_LIBS
@@ -61,6 +35,38 @@ COOKIEFILE="@PREFIX@/var/lib/membase/membase-server.cookie"
couch_start_arguments=""
+_check_nofile () {
+ if [ `ulimit -n` -lt 10240 ]
+ then
+ cat <<EOF
+The maximum number of open files for the membase user is set too low.
+It must be at least 10240. Normally this can be increased by adding
+the following lines to /etc/security/limits.conf:
+
+couchbase soft nofile <value>
+couchbase hard nofile <value>
+
+Where <value> is greater than 10240.
+EOF
+ fi
+}
+
+_prepare_datadir () {
+ datadir="@PREFIX@/var/lib/membase"
+
+ test -d "$datadir" || mkdir -p "$datadir"
+ cd "$datadir"
+}
+
+_maybe_start_epmd () {
+ # Initialize distributed erlang on the system (i.e. epmd)
+ erl -noshell -setcookie nocookie -sname init -run init stop 2>&1 > /dev/null
+ if [ $? -ne 0 ]
+ then
+ exit 1
+ fi
+}
+
_add_config_file () {
couch_start_arguments="$couch_start_arguments $1"
}
@@ -85,6 +91,9 @@ _load_config () {
}
_start() {
+ _check_nofile
+ _prepare_datadir
+ _maybe_start_epmd
_load_config
exec erl \
Please sign in to comment.
Something went wrong with that request. Please try again.