Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
grafana rc.d scripts reports process not running
Hi!
I'm currently trying out grafana, and I noticed one weirdness after
starting it using the pkgsrc rc.d script.
# /etc/rc.d/grafana status
grafana is not running.
# cat /var/run/grafana.pid
21719# ps -auxwww | grep 21719
root 7846 0.0 0.0 12468 2212 pts/4 O+ 3:14nachm. 0:00.00 grep 21719
grafana 21719 0.0 0.1 1681352 157636 pts/4 Sl 3:08nachm. 0:02.15 grafana server -homepath /usr/pkg/share/grafana -config /usr/pkg/etc/grafana.conf -pidfile /var/run/grafana.pid
So grafana saved its PID into /var/run/grafana.pid, which is what's
configured in the rc.d script as pidfile, but the status command
thinks it's not running, despite a grafana process with the
corresponding PID running. (I tried manually adding a newline to the
pidfile, but that doesn't change the behaviour.)
There is not even an interpreter involved, /usr/pkg/bin/grafana is a
go binary.
Does anyone have an idea what the problem could be here?
grafana rc.d script attached.
Thanks,
Thomas
#!/bin/sh
#
# $NetBSD: grafana.sh,v 1.6 2022/11/29 22:06:47 wiz Exp $
#
# PROVIDE: grafana
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Consider installing pkgtools/rc.subr in unprivileged.
#
# You will need to set some variables in /etc/rc.conf to start grafana:
#
# grafana=YES
if [ -f /etc/rc.subr ]; then
$_rc_subr_loaded . /etc/rc.subr
fi
name="grafana"
rcvar=$name
grafana_user="grafana"
grafana_group="grafana"
grafana_home="/usr/pkg/share/${name}"
pidfile="/var/run/${name}.pid"
command="/usr/pkg/bin/grafana-server"
command_args="-homepath ${grafana_home} -config /usr/pkg/etc/grafana.conf -pidfile ${pidfile} < /dev/null > /dev/null 2>&1 &"
start_precmd="grafana_precmd"
grafana_precmd() {
if [ ! -r "${pidfile}" ]; then
touch "${pidfile}"
chown "${grafana_user}:${grafana_group}" "${pidfile}"
chmod 644 "${pidfile}"
fi
}
if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
load_rc_config $name
run_rc_command "$1"
else
if [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi
case "$1" in
start)
if [ -r "${pidfile}" ]; then
echo "Already running ${name}."
else
echo "Starting ${name}."
eval ${command} ${command_args}
fi
;;
stop)
if [ -r "${pidfile}" ]; then
echo "Stopping ${name}."
kill `/bin/cat "${pidfile}"` && /bin/rm "${pidfile}"
fi
;;
*)
echo "Usage: $0 {start|stop}" 1>&2
exit 10
;;
esac
fi
Home |
Main Index |
Thread Index |
Old Index