#!/sbin/openrc-run

name=rabbitmq
description="RabbitMQ Server"

command=/usr/sbin/rabbitmq-server
command_background=true
command_user="rabbitmq:rabbitmq"
pidfile=/run/rabbitmq/rabbitmq.pid

export RABBITMQ_PID_FILE="$pidfile"

output_log="/var/log/rabbitmq/${RC_SVCNAME}_log"
error_log="/var/log/rabbitmq/${RC_SVCNAME}_err"

depend() {
	need net localmount
	after firewall
}

start_pre() {
	# We need to test if /var/run/rabbitmq exists, since script will fail if it does not
	checkpath -m 700 -o "$command_user" -d "$(dirname "$pidfile")"
	checkpath -q -m 644 -o "$command_user" --file-truncate -f $output_log
	checkpath -q -m 644 -o "$command_user" --file-truncate -f $error_log
}
