aboutsummaryrefslogtreecommitdiffstats
path: root/testing/rabbitmq-server/rabbitmq-server.initd
blob: caca99463c337e118dc8ba27104bf0ca429de7de (plain)
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
#!/sbin/openrc-run

pidfile=/run/rabbitmq/rabbitmq.pid
name=rabbitmq
daemon=/usr/sbin/rabbitmq-server

startup_log=/var/log/rabbitmq/startup_log
startup_err=/var/log/rabbitmq/startup_err
shutdown_log=/var/log/rabbitmq/shutdown_log
shutdown_err=/var/log/rabbitmq/shutdown_err

depend() {
	need net localmount
	after firewall
}

start() {
	ebegin "Starting ${name}"
	# We need to test if /var/run/rabbitmq exists, since scirpt will fail if it does not
	checkpath -m 700 -o rabbitmq:rabbitmq -d "$(dirname "$pidfile")"
	checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $startup_log
	checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $startup_err
	start-stop-daemon --start \
		--env RABBITMQ_PID_FILE=$pidfile \
		--pidfile $pidfile \
		--stdout $startup_log \
		--stderr $startup_err \
		--background $daemon
	eend $?
}

stop() {
	ebegin "Stopping ${name}"
	checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $shutdown_log
	checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $shutdown_err
	start-stop-daemon --stop --quiet --pidfile $pidfile \
		--exec /bin/sh -- -c "/usr/sbin/rabbitmqctl \
		--stop $pidfile > $shutdown_log \
		2> $shutdown_err"
	eend $?
}