summaryrefslogtreecommitdiff
path: root/databases/mongodb34-rocks/files/mongos.in
blob: b1d2da68eb0e23ed5e8b12535765ad7d248b034c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

# PROVIDE: mongos
# REQUIRE: NETWORK ldconfig
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# mongos_enable (bool):  Set to "NO" by default.
#                        Set it to "YES" to enable mongos.
# mongos_limits (bool):  Set to "NO" by default.
#                        Set it to yes to run `limits -e -U mongodb`
#                        just before mongos starts.
# mongos_flags (str):    Custom additional arguments to be passed to mongos.
#                        Default to "--logpath /var/log/mongodb/mongos.log --logappend".
# mongos_config (str):	 Default to "%%PREFIX%%/etc/mongos.conf"
#                        Path to config file
#

. /etc/rc.subr

name="mongos"
rcvar=mongos_enable

load_rc_config $name

: ${mongos_enable="NO"}
: ${mongos_limits="NO"}
: ${mongos_logpath="/var/log/mongodb"}
: ${mongos_runpath="/var/run/mongodb"}
: ${mongos_flags="--logpath ${mongos_logpath}/mongos.log --logappend"}
: ${mongos_user="mongodb"}
: ${mongos_group="mongodb"}
: ${mongos_config="%%PREFIX%%/etc/mongos.conf"}

pidfile="${mongos_runpath}/mongos.pid"
command=%%PREFIX%%/bin/${name}
command_args="--config $mongos_config --fork >/dev/null 2>/dev/null"
start_precmd="${name}_prestart"

mongos_create_dbpath()
{
        install -d -g ${mongos_group} -o ${mongos_user} -m 755 ${mongos_logpath}
        install -d -g ${mongos_group} -o ${mongos_user} -m 755 ${mongos_runpath}
}

mongos_prestart()
{
        if [ ! -d ${mongos_logpath} ]; then
                mongos_create_dbpath || return 1
        fi
        if checkyesno mongos_limits; then
                eval `/usr/bin/limits -e -U ${mongos_user}` 2>/dev/null
        else
                return 0
        fi
}

run_rc_command "$1"