aboutsummaryrefslogtreecommitdiff
path: root/databases/mongodb/files/mongod.in
diff options
context:
space:
mode:
Diffstat (limited to 'databases/mongodb/files/mongod.in')
-rw-r--r--databases/mongodb/files/mongod.in64
1 files changed, 37 insertions, 27 deletions
diff --git a/databases/mongodb/files/mongod.in b/databases/mongodb/files/mongod.in
index 272ecbea3ca7..a06b88ff5226 100644
--- a/databases/mongodb/files/mongod.in
+++ b/databases/mongodb/files/mongod.in
@@ -7,45 +7,55 @@
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
-# mongod_enable (bool): Set to NO by default.
-# Set it to YES to enable mongod.
+# mongod_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable mongod.
+# mongod_limits (bool): Set to "NO" by default.
+# Set it to yes to run `limits -e -U mongodb`
+# just before mongod starts.
+# mongod_dbpath (str): Default to "/var/db/mongodb"
+# Base database directory.
+# mongod_pidfile (str): Custum PID file path and name.
+# Default to "${mongod_dbpath}/mongod.pid".
+# mongod_flags (str): Custom additional arguments to be passed to mongod.
+# Default to "--logpath ${mongod_dbpath}/mongod.log --logappend".
#
-# Additional configurable variables:
-# mongod_config (path): Set to %%PREFIX%%/etc/mongodb.conf
-# by default. Additional configuration. You
-# can also use mongod_flags for additional
-# command line arguments.
-# mongod_dbpath (path): Set to /var/db/mongodb by default
-# mongod_user (username): Set to "mongodb" by default
. /etc/rc.subr
name="mongod"
rcvar=mongod_enable
-command=%%PREFIX%%/bin/${name}
-
load_rc_config $name
: ${mongod_enable="NO"}
-: ${mongod_config="%%PREFIX%%/etc/mongodb.conf"}
+: ${mongod_limits="NO"}
: ${mongod_dbpath="/var/db/mongodb"}
+: ${mongod_flags="--logpath ${mongod_dbpath}/mongod.log --logappend"}
: ${mongod_user="mongodb"}
+: ${mongod_group="mongodb"}
-# Note: if you use a config file for mongodb,
-# the parameters passed on cl override the config file
-# ie, dbpath, logappend, logpath etc in the command_args below.
-# This means that your config file will be ignored unless
-# you comment out remove the cl parameters.
-#
-# Using config file: uncomment the following line AND comment out
-# the next line.
-
-# command_args="-f $mongod_config"
-
-command_args="-f $mongod_config --dbpath $mongod_dbpath --logappend --logpath $mongod_dbpath/mongod.log --fork"
-
-required_dirs=${mongod_dbpath}
+pidfile=${mongod_pidfile:-"${mongod_dbpath}/mongod.pid"}
+command=%%PREFIX%%/bin/${name}
+command_args="--config %%PREFIX%%/etc/mongodb.conf --dbpath $mongod_dbpath --pidfilepath ${pidfile} --fork"
+start_precmd="${name}_prestart"
+
+mongod_create_dbpath()
+{
+ mkdir ${mongod_dbpath} >/dev/null 2>/dev/null
+ [ $? -eq 0 ] && chown -R ${mongod_user}:${mongod_group} ${mongod_dbpath}
+}
+
+
+mongod_prestart()
+{
+ if [ ! -d ${mongod_dbpath} ]; then
+ mongod_create_dbpath || return 1
+ fi
+ if checkyesno mongod_limits; then
+ eval `/usr/bin/limits -e -U ${mongod_user}` 2>/dev/null
+ else
+ return 0
+ fi
+}
run_rc_command "$1"
-