summaryrefslogtreecommitdiff
path: root/sysutils/cbsd/files/cbsd-statsd-bhyve.in
diff options
context:
space:
mode:
authorKirill Ponomarev <krion@FreeBSD.org>2023-04-11 17:02:16 +0200
committerKirill Ponomarev <krion@FreeBSD.org>2023-04-11 17:02:16 +0200
commit45b352edf6d039b3fc820ca523fb7aef3c093906 (patch)
tree8879081def81663f313da07f35e3235f11a19ec6 /sysutils/cbsd/files/cbsd-statsd-bhyve.in
parentjapanese/font-udev-gothic{,-nf}: update to 1.2.0. (diff)
sysutils/cbsd: Update to 13.2.0
Changes: https://github.com/cbsd/cbsd/releases/tag/v13.2.0
Diffstat (limited to 'sysutils/cbsd/files/cbsd-statsd-bhyve.in')
-rw-r--r--sysutils/cbsd/files/cbsd-statsd-bhyve.in43
1 files changed, 39 insertions, 4 deletions
diff --git a/sysutils/cbsd/files/cbsd-statsd-bhyve.in b/sysutils/cbsd/files/cbsd-statsd-bhyve.in
index be56087326c1..14de0265d510 100644
--- a/sysutils/cbsd/files/cbsd-statsd-bhyve.in
+++ b/sysutils/cbsd/files/cbsd-statsd-bhyve.in
@@ -20,14 +20,18 @@ export workdir="${cbsd_workdir}"
globalconf=${cbsd_globalconf:-"%%PREFIX%%/cbsd/cbsd.conf"}
start_cmd=${name}_start
+stop_cmd=${name}_stop
restart_cmd=${name}_restart
extra_commands="restart"
command="%%PREFIX%%/cbsd/tools/racct-bhyve-statsd"
-pidfile="/var/run/$name.pid"
-command_args="&"
+pidfile="${cbsd_workdir}/var/run/${name}.pid"
+daemon_pidfile="${cbsd_workdir}/var/run/${name}-daemon.pid"
+daemon_logdir="/var/log/${name}"
+workdir_normalize=$( echo ${cbsd_workdir} | /usr/bin/tr "/" "_" )
+daemon_logfile="${daemon_logdir}/cbsd-statsd-bhyve${workdir_normalize}.log"
-pidfile=/var/run/racct-bhyve-statsd.pid
+command_args="&"
if [ ! -f ${globalconf} ]; then
echo "cbsd: no such ${globalconf}";
@@ -42,6 +46,34 @@ fi
. ${globalconf}
. ${subrdir}/nc.subr
+cbsd_statsd_bhyve_stop()
+{
+ local _pids
+
+ if [ -f "${daemon_pidfile}" ]; then
+ _pids=$( pgrep -F ${daemon_pidfile} 2>&1 )
+ _err=$?
+ /bin/rm -f ${daemon_pidfile}
+ if [ ${_err} -eq 0 ]; then
+ kill -9 ${_pids}
+ else
+ echo "pgrep: ${_pids}"
+ fi
+ fi
+ if [ -f "${pidfile}" ]; then
+ _pids=$( pgrep -F ${pidfile} 2>&1 )
+ _err=$?
+ /bin/rm -f ${pidfile}
+ if [ ${_err} -eq 0 ]; then
+ kill -9 ${_pids}
+ else
+ echo "pgrep: ${_pids}"
+ fi
+ fi
+
+ return 0
+}
+
cbsd_statsd_bhyve_start()
{
local args= racct_enabled=
@@ -84,7 +116,10 @@ cbsd_statsd_bhyve_start()
;;
esac
- exec env workdir=${cbsd_workdir} %%PREFIX%%/cbsd/tools/racct-bhyve-statsd ${args}
+ [ ! -d ${daemon_logdir} ] && mkdir -p ${daemon_logdir}
+ touch ${daemon_logfile}
+
+ /usr/sbin/daemon -f -R5 -P ${daemon_pidfile} -o ${daemon_logfile} /usr/bin/env workdir=${cbsd_workdir} ${command} ${args}
}
cbsd_statsd_bhyve_restart()