freebsd-ports/databases/couchdb/files/couchdb.in
Jimmy Olgeni 2bc036ce3b Allow passing ERL_ZFLAGS to CouchDB via couchdb_erl_flags in rc.conf.
ERL_ZFLAGS is used to configure the Erlang VM itself (see also
erl(1), "EMULATOR FLAGS")

PR:		197847
Submitted by:	Dave Cottlehuber
2015-02-24 14:56:22 +00:00

83 lines
2.0 KiB
Bash

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: couchdb
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# couchdb_enable (bool): Set to NO by default.
# Set it to YES to enable couchdb.
#
# couchdb_enablelogs (bool): Set to YES by default.
#
# couchdb_etcdir (string): In case you want another dir
# for default.ini/local.ini.
#
# couchdb_respawn (int): Set to none by default. If CouchDB crashes,
# respawn after this many seconds.
#
# couchdb_erl_flags (string): Set to none by default. Additional Erlang flags
# that are appended via ERL_ZFLAGS to the Erlang VM parameters.
. /etc/rc.subr
name="couchdb"
rcvar=couchdb_enable
load_rc_config $name
: ${couchdb_enable:="NO"}
couchdb_user="${couchdb_user:-"couchdb"}"
couchdb_enablelogs="${couchdb_enablelogs:-"YES"}"
couchdb_etcdir="${couchdb_etcdir:-"%%PREFIX%%/etc/couchdb"}"
couchdb_respawn="${couchdb_respawn:-"0"}"
couchdb_erl_flags="${couchdb_erl_flags:-""}"
command="%%PREFIX%%/bin/${name}"
pidfile="/var/run/${name}/${name}.pid"
urifile="/var/run/${name}/couch.uri"
command_args="-p ${pidfile} -b"
couchdb_prestart()
{
install -o $couchdb_user /dev/null $pidfile
install -o $couchdb_user /dev/null $urifile
if [ -n "$couchdb_flags" ]; then
case "$couchdb_flags" in
*-[bp]*) err 1 'The -b and -p options should be removed from couchdb_flags' ;;
esac
return 0
fi
if [ $couchdb_respawn -gt 0 ]; then
respawn="-r ${couchdb_respawn}"
fi
if checkyesno couchdb_enablelogs; then
logfile=/var/log/${name}/couch.log
errfile=/var/log/${name}/err.log
else
logfile=/dev/null
errfile=/dev/null
fi
# couchdb supports passing options through to the erlang vm directly in
# ERL_ZFLAGS which is appended to CouchDB own flags.
ERL_ZFLAGS=${couchdb_erl_flags}
export ERL_ZFLAGS
command_args="-a ${couchdb_etcdir}/default.ini -a ${couchdb_etcdir}/local.ini ${respawn} -o ${logfile} -e ${errfile} ${command_args}"
}
start_precmd=${name}_prestart
stop_cmd="${command} -d"
status_cmd="${command} -s"
run_rc_command "$1"