Changeset View
Changeset View
Standalone View
Standalone View
databases/mongodb50/files/mongod.in
#!/bin/sh | #!/bin/sh | ||||
# PROVIDE: mongod | # PROVIDE: mongod | ||||
# REQUIRE: NETWORK ldconfig | # REQUIRE: NETWORK ldconfig | ||||
# KEYWORD: shutdown | # KEYWORD: shutdown | ||||
# | # | ||||
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf | # Add the following lines to /etc/rc.conf.local or /etc/rc.conf | ||||
# to enable this service: | # to enable this service: | ||||
# | # | ||||
# mongod_enable (bool): Set to "NO" by default. | # mongod_enable (bool): Set to "NO" by default. | ||||
# Set it to "YES" to enable mongod. | # Set it to "YES" to enable mongod. | ||||
%%LEGACY_LIMITS%%# mongod_limits (bool): Set to "NO" by default. | |||||
%%LEGACY_LIMITS%%# Set it to yes to run `limits -e -U mongodb` | |||||
%%LEGACY_LIMITS%%# just before mongod starts. | |||||
# mongod_dbpath (str): Default to "/var/db/mongodb" | # mongod_dbpath (str): Default to "/var/db/mongodb" | ||||
# Base database directory. | # Base database directory. | ||||
# mongod_flags (str): Custom additional arguments to be passed to mongod. | # mongod_flags (str): Custom additional arguments to be passed to mongod. | ||||
# Default to "--logpath ${mongod_dbpath}/mongod.log --logappend". | # Default to "--logpath ${mongod_dbpath}/mongod.log --logappend". | ||||
# mongod_config (str): Default to "%%PREFIX%%/etc/mongodb.conf" | # mongod_config (str): Default to "%%PREFIX%%/etc/mongodb.conf" | ||||
# Path to config file | # Path to config file | ||||
# | # | ||||
. /etc/rc.subr | . /etc/rc.subr | ||||
name="mongod" | name="mongod" | ||||
rcvar=mongod_enable | rcvar=mongod_enable | ||||
load_rc_config $name | load_rc_config $name | ||||
: ${mongod_enable="NO"} | : ${mongod_enable="NO"} | ||||
%%LEGACY_LIMITS%%: ${mongod_limits="NO"} | |||||
: ${mongod_dbpath="/var/db/mongodb"} | : ${mongod_dbpath="/var/db/mongodb"} | ||||
: ${mongod_flags="--logpath ${mongod_dbpath}/mongod.log --logappend --setParameter=disabledSecureAllocatorDomains=\*"} | : ${mongod_flags="--logpath ${mongod_dbpath}/mongod.log --logappend --setParameter=disabledSecureAllocatorDomains=\*"} | ||||
: ${mongod_user="mongodb"} | : ${mongod_user="mongodb"} | ||||
: ${mongod_group="mongodb"} | : ${mongod_group="mongodb"} | ||||
: ${mongod_config="%%PREFIX%%/etc/mongodb.conf"} | : ${mongod_config="%%PREFIX%%/etc/mongodb.conf"} | ||||
pidfile="${mongod_dbpath}/mongod.lock" | pidfile="${mongod_dbpath}/mongod.lock" | ||||
command=%%PREFIX%%/bin/${name} | command=%%PREFIX%%/bin/${name} | ||||
command_args="--config $mongod_config --dbpath $mongod_dbpath --fork >/dev/null 2>/dev/null" | command_args="--config $mongod_config --dbpath $mongod_dbpath --fork >/dev/null 2>/dev/null" | ||||
start_precmd="${name}_prestart" | start_precmd="${name}_prestart" | ||||
mongod_create_dbpath() | mongod_create_dbpath() | ||||
{ | { | ||||
mkdir ${mongod_dbpath} >/dev/null 2>/dev/null | mkdir ${mongod_dbpath} >/dev/null 2>/dev/null | ||||
[ $? -eq 0 ] && chown -R ${mongod_user}:${mongod_group} ${mongod_dbpath} | [ $? -eq 0 ] && chown -R ${mongod_user}:${mongod_group} ${mongod_dbpath} | ||||
} | } | ||||
mongod_prestart() | mongod_prestart() | ||||
{ | { | ||||
if [ ! -d ${mongod_dbpath} ]; then | if [ ! -d ${mongod_dbpath} ]; then | ||||
mongod_create_dbpath || return 1 | mongod_create_dbpath || return 1 | ||||
fi | fi | ||||
%%LEGACY_LIMITS%% if checkyesno mongod_limits; then | return 0 | ||||
%%LEGACY_LIMITS%% eval `/usr/bin/limits -e -U ${mongod_user}` 2>/dev/null | |||||
%%LEGACY_LIMITS%% else | |||||
%%LEGACY_LIMITS%% return 0 | |||||
%%LEGACY_LIMITS%% fi | |||||
%%MODERN_LIMITS%% return 0 | |||||
} | } | ||||
run_rc_command "$1" | run_rc_command "$1" |