aboutsummaryrefslogtreecommitdiffstats
path: root/testing/logstash/logstash.initd
blob: b022fd387bf9f20e7ee6520635ad331174a6daf9 (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
#!/sbin/openrc-run
supervisor=supervise-daemon

description="logs, events, or other data transporter"

: ${LS_USER:="logstash"}
: ${LS_GROUP:="$(id -gn $LS_USER)"}

nice="19"
pidfile="/run/$RC_SVCNAME.sd.pid"
supervise_daemon_args="-u $LS_USER -g $LS_GROUP -p $pidfile -N $nice"
command=/usr/share/logstash/bin/logstash
command_args="--path.settings ${LS_CONF} ${LS_OPTS}"
max_fd="16384"

depends() {
	use net
}

in_contr() {
	grep "container=" /proc/1/environ
}

start_pre() {
	local dir

	# Note: checkpath doesn't create intermediate directories.
	for dir in "${LS_HOME}" "${LS_DATA}" "${LS_LOGS}"; do
		mkdir -p "$(dirname "$dir")"
	done

	checkpath -d -o $LS_USER:$LS_GROUP -m755 "${LS_HOME}"
	checkpath -d -o $LS_USER:$LS_GROUP -m700 "${LS_DATA}"
	checkpath -d -o $LS_USER:$LS_GROUP -m755 "${LS_LOGS}"

	if [ -n "$max_fd" ]; then
		if [ -z "$(in_contr)" ]; then
			ulimit -n "$max_fd" && einfo "Max open filedescriptors: $max_fd"
		else
			einfo "Run 'ulimit -n $max_fd' on the container host"
		fi
	fi
}