summaryrefslogtreecommitdiff
path: root/net-mgmt/netbox/files/netboxrc.sample.in
blob: 2502f9c0b14e9c50a8cb2881407247547055fb22 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh

# This sample rc script eliminate the need to use sysutils/py-supervisor to
# run NetBox as a system service. Only www/py-gunicorn is needed as a WSGI.
#
# Of course a working HTTP server like Apache/nginx is still required to make
# use of the gunicorn WSGI.

#
# PROVIDE: netbox
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf.local or /etc/rc.conf
# to enable netbox:
#
# netbox_enable (bool):			Set to NO by default.
#					Set it to YES to enable netbox.
# netbox_use_config (bool):		Set to NO by default.
#					If set, read the configuration parameter from file defined in
#					"netbox_config" instead using rc variables.
# netbox_config (str):			Default to "/usr/local/etc/${name}.conf}"
#					Config file for gunicorn's netbox config file
# netbox_command (str):			Default to "%%LOCALBASE%%/bin/gunicorn"
#					Path to gunicorn to run netbox
# netbox_bind (str):    		Default to "localhost:8001"
#					Interface and port to bind to
# netbox_workers (int):			Default to "5"
#					Number of gunicorn workers
# netbox_threads (int):			Default to "3"
#					Number of worker threads per handling request
# netbox_timeout (int):			Default to "120"
#					Worker timeout for gunicorn
# netbox_max_requests (int):		Default to "5000"
#					Maximum number of requests a worker process will process before respawning
# netbox_max_requests_jitter (int):	Default to "500"
#					Maximum number jitter to add to "netbox_max_requests"
# netbox_extra_args (str):		Not set by default
#					Extra arguments that are passed to gunicorn
#

. /etc/rc.subr

name="netbox"
rcvar=netbox_enable
netbox_path=%%DATADIR%%

load_rc_config $name

start_precmd="netbox_precmd"
command=${netbox_program:-%%LOCALBASE%%/bin/gunicorn}
procname=${netbox_procname:-%%PYTHON_CMD%%}
netbox_chdir=${netbox_path}
pidfile=${netbox_pidfile:-/var/run/${name}/${name}.pid}
netbox_user=${netbox_user:-%%WWWOWN%%}
netbox_use_config=${netbox_use_config:-no}
netbox_config=${netbox_config:-/${name}.conf}
netbox_bind=${netbox_bind:-localhost:8001}
netbox_workers=${netbox_workers:-5}
netbox_threads=${netbox_threads:-3}
netbox_timeout=${netbox_timeout:-120}
netbox_max_requests=${netbox_max_requests:-5000}
netbox_max_requests_jitter=${netbox_max_requests_jitter:-500}

# Read settings from confguration file if set
if checkyesno netbox_use_config && [ -f "${netbox_config}" ]; then 
	command_args="${netbox_args} -D \
		--log-syslog --log-syslog-prefix ${name} \
		--log-syslog-to unix:///var/run/log#dgram \
		--disable-redirect-access-to-syslog \
		-p ${pidfile} --pythonpath ${netbox_path} \
		-c ${netbox_config} \
		netbox.wsgi"
else
	command_args="${netbox_args} -D \
		--log-syslog --log-syslog-prefix ${name} \
		--log-syslog-to unix:///var/run/log#dgram \
		--disable-redirect-access-to-syslog \
		-p ${pidfile} --pythonpath ${netbox_path} \
		-b ${netbox_bind} -w ${netbox_workers} --threads ${netbox_threads} -t ${netbox_timeout} \
		--max-requests ${netbox_max_requests} --max-requests-jitter ${netbox_max_requests_jitter} \
		${netbox_extra_args} \
		netbox.wsgi"
fi

netbox_precmd()
{
	install -d -o ${netbox_user} `dirname ${pidfile}`
}

run_rc_command "$1"