You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ns...@apache.org on 2008/06/20 00:12:02 UTC
svn commit: r669725 -
/incubator/couchdb/branches/runtimeconfig/bin/couchdb.tpl.in
Author: nslater
Date: Thu Jun 19 15:12:02 2008
New Revision: 669725
URL: http://svn.apache.org/viewvc?rev=669725&view=rev
Log:
initial stab at multiple configuration files
Modified:
incubator/couchdb/branches/runtimeconfig/bin/couchdb.tpl.in
Modified: incubator/couchdb/branches/runtimeconfig/bin/couchdb.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/bin/couchdb.tpl.in?rev=669725&r1=669724&r2=669725&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/bin/couchdb.tpl.in (original)
+++ incubator/couchdb/branches/runtimeconfig/bin/couchdb.tpl.in Thu Jun 19 15:12:02 2008
@@ -28,7 +28,9 @@
LIB_DIRECTORY=%localstatelibdir%
LOG_DIRECTORY=%localstatelogdir%
-INI_FILE=%localconfdir%/couch.ini
+DEFAULT_INI_FILE=%localconfdir%/default.ini
+LOCAL_INI_FILE=%localconfdir%/local.ini
+
PID_FILE=%localstatedir%/run/couchdb.pid
STDOUT_FILE=couchdb.stdout
@@ -72,7 +74,7 @@
-h display a short help message and exit
-V display version information and exit
- -c FILE set the configuration FILE (defaults to $INI_FILE)
+ -c FILE add a configuration FILE (defaults to $DEFAULT_INI_FILE and $LOCAL_INI_FILE)
-i use the interactive Erlang shell
-b spawn as a background process
-p FILE set the background PID FILE (defaults to $PID_FILE)
@@ -96,17 +98,6 @@
exit $SCRIPT_ERROR
}
-_load_configuration () {
- dbrootdir_ini_value=`%AWK% -F = "/^DbRootDir=/{print \\$2}" < $INI_FILE`
- if test -n "$dbrootdir_ini_value"; then
- LIB_DIRECTORY=$dbrootdir_ini_value
- fi
- logfile_ini_value=`%AWK% -F = "/^LogFile=/{print \\$2}" < $INI_FILE`
- if test -n "$logfile_ini_value"; then
- LOG_DIRECTORY=`dirname $logfile_ini_value`
- fi
-}
-
_get_pid () {
if test -f $PID_FILE; then
PID=`cat $PID_FILE`
@@ -132,59 +123,37 @@
}
check_environment () {
+ if test "$BACKGROUND_BOOLEAN" != "true"; then
+ return
+ fi
+ touch $PID_FILE 2> /dev/null || true
+ touch $STDOUT_FILE 2> /dev/null || true
+ touch $STDERR_FILE 2> /dev/null || true
message_prefix="Apache CouchDB needs write permission on the"
- if test ! -w $LIB_DIRECTORY; then
- echo "$message_prefix data directory: $LIB_DIRECTORY" >&2
+ if test ! -w $PID_FILE; then
+ echo "$message_prefix PID file: $PID_FILE" >&2
exit $SCRIPT_ERROR
fi
- if test ! -w $LOG_DIRECTORY; then
- echo "$message_prefix log directory: $LOG_DIRECTORY" >&2
+ if test ! -w $STDOUT_FILE; then
+ echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2
exit $SCRIPT_ERROR
fi
- message_prefix="Apache CouchDB needs write permission on data file"
- for file in `find $LIB_DIRECTORY -type f`; do
- if test ! -w $file; then
- echo "$message_prefix: $file" >&2
- exit $SCRIPT_ERROR
- fi
- done
- message_prefix="Apache CouchDB needs write permission on log file"
- for file in `find $LOG_DIRECTORY -type f`; do
- if test ! -w $file; then
- echo "$message_prefix: $file" >&2
- exit $SCRIPT_ERROR
- fi
- done
- if test "$BACKGROUND_BOOLEAN" = "true"; then
- touch $PID_FILE 2> /dev/null || true
- touch $STDOUT_FILE 2> /dev/null || true
- touch $STDERR_FILE 2> /dev/null || true
- message_prefix="Apache CouchDB needs write permission on the"
- if test ! -w $PID_FILE; then
- echo "$message_prefix PID file: $PID_FILE" >&2
- exit $SCRIPT_ERROR
- fi
- if test ! -w $STDOUT_FILE; then
- echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2
- exit $SCRIPT_ERROR
- fi
- if test ! -w $STDERR_FILE; then
- echo "$message_prefix STDERR file: $STDERR_FILE" >&2
- exit $SCRIPT_ERROR
- fi
- message_prefix="Apache CouchDB needs a regular"
- if ! echo 2> /dev/null >> $PID_FILE; then
- echo "$message_prefix PID file: $PID_FILE" >&2
- exit $SCRIPT_ERROR
- fi
- if ! echo 2> /dev/null >> $STDOUT_FILE; then
- echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2
- exit $SCRIPT_ERROR
- fi
- if ! echo 2> /dev/null >> $STDERR_FILE; then
- echo "$message_prefix STDERR file: $STDERR_FILE" >&2
- exit $SCRIPT_ERROR
- fi
+ if test ! -w $STDERR_FILE; then
+ echo "$message_prefix STDERR file: $STDERR_FILE" >&2
+ exit $SCRIPT_ERROR
+ fi
+ message_prefix="Apache CouchDB needs a regular"
+ if ! echo 2> /dev/null >> $PID_FILE; then
+ echo "$message_prefix PID file: $PID_FILE" >&2
+ exit $SCRIPT_ERROR
+ fi
+ if ! echo 2> /dev/null >> $STDOUT_FILE; then
+ echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2
+ exit $SCRIPT_ERROR
+ fi
+ if ! echo 2> /dev/null >> $STDERR_FILE; then
+ echo "$message_prefix STDERR file: $STDERR_FILE" >&2
+ exit $SCRIPT_ERROR
fi
}
@@ -203,9 +172,18 @@
touch $PID_FILE
interactive_option="+Bd -noinput"
fi
-
- ini_file_list="[\\\"$INI_FILE\\\"]"
-
+ if test -n "$INI_FILES"; then
+ ini_files="$INI_FILES"
+ else
+ ini_files="$DEFAULT_INI_FILE $LOCAL_INI_FILE"
+ fi
+ for file in $ini_files; do
+ if test -n "$start_arguments"; then
+ start_arguments="$start_arguments, ";
+ fi
+ start_arguments="$start_arguments \"../$file\""
+ done
+ echo $start_arguments
command="`%ICU_CONFIG% --invoke` \
%ERL% $interactive_option -smp auto -sasl errlog_type error \
-pa %localerlanglibdir%/couch-%version%/ebin \
@@ -215,8 +193,7 @@
-eval \"application:load(couch)\" \
-eval \"crypto:start()\" \
-eval \"inets:start()\" \
- -eval \"couch_server:start($ini_file_list), receive done -> done end.\" "
-
+ -eval \"couch_server:start([\\\"$start_arguments\\\"]), receive done -> done end.\" "
if test "$BACKGROUND_BOOLEAN" = "true" \
-a "$RECURSED_BOOLEAN" = "false"; then
$0 -c $INI_FILE -b -r $RESPAWN_TIMEOUT -p $PID_FILE \
@@ -295,7 +272,7 @@
case "$1" in
-h) shift; display_help; exit $SCRIPT_OK;;
-V) shift; display_version; exit $SCRIPT_OK;;
- -c) shift; INI_FILE=$1; shift;;
+ -c) shift; INI_FILES="$INI_FILES $1"; shift;;
-i) shift; INTERACTIVE_BOOLEAN=true;;
-b) shift; BACKGROUND_BOOLEAN=true;;
-r) shift; RESPAWN_TIMEOUT=$1; shift;;
@@ -310,7 +287,6 @@
*) display_error "Unknown option: $1" >&2;;
esac
done
- _load_configuration
if test "$KILL_BOOLEAN" = "true" -o "$SHUTDOWN_BOOLEAN" = "true"; then
stop_couchdb $KILL_BOOLEAN
else