#!/sbin/openrc-run

extra_started_commands="reload"

description="PgQ maintenance daemon"
description_reload="Reload the configuration"

: ${command_user:="postgres"}
: ${cfgfile:="/etc/pgqd.ini"}

command="/usr/bin/pgqd"
command_args="$command_args $cfgfile"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"

depend() {
	use logger
	after postgresql
}

reload() {
	ebegin "Reloading $RC_SVCNAME configuration"

	if [ "$supervisor" ]; then
		$supervisor "$RC_SVCNAME" --signal HUP
	else
		start-stop-daemon --pidfile "$pidfile" --signal HUP
	fi

	eend $?
}
