- Add nats to UIDs and GIDs
- Add extra commands for logrotate and 'lame duck mode'.
From the docs:
In production we recommend that a server is shut down with "lame duck mode"
as a graceful way to slowly evict clients. With large deployments this
mitigates the "thundering herd" situation that will place CPU pressure on
servers as TLS enabled clients reconnect.
After entering lame duck mode, the server will stop accepting new
connections, wait for a 10 second grace period, then begin to evict clients
over a period of time configurable by the configuration option. This
period defaults to 2 minutes.
45 lines
970 B
Bash
45 lines
970 B
Bash
#!/bin/sh
|
|
#
|
|
# PROVIDE: nats
|
|
# REQUIRE: DAEMON
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following lines to /etc/rc.conf to run NATS:
|
|
#
|
|
# nats_enable (bool): Set it to "YES" to enable nats server.
|
|
# Default is "NO".
|
|
# nats_user: User name to run as. default "nats"
|
|
# nats_group: Group name to run as. default "nats"
|
|
# nats_options: Options to pass nats server
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name=nats
|
|
rcvar=`set_rcvar`
|
|
|
|
load_rc_config ${name}
|
|
|
|
: ${nats_enable:=NO}
|
|
: ${nats_user:=nats}
|
|
: ${nats_group:=nats}
|
|
: ${nats_options="-c %%PREFIX%%/etc/nats.conf"}
|
|
|
|
start_precmd=nats_start_precmd
|
|
|
|
pidfile="/var/run/${name}.pid"
|
|
procname=%%PREFIX%%/bin/nats-server
|
|
command=/usr/sbin/daemon
|
|
command_args="-p ${pidfile} ${procname} ${nats_options}"
|
|
|
|
extra_commands="logrotate ldm"
|
|
logrotate_cmd="${procname} --signal reopen=${pidfile}"
|
|
ldm_cmd="${procname} --signal ldm=${pidfile}"
|
|
|
|
nats_start_precmd()
|
|
{
|
|
install -o ${nats_user} -g ${nats_group} /dev/null ${pidfile}
|
|
}
|
|
|
|
run_rc_command "$1"
|